flickeringpixel
Forum Replies Created
Viewing 3 replies - 1 through 3 (of 3 total)
-
Forum: Plugins
In reply to: [WooCommerce Extended Coupon Features FREE] Discount on original priceIn case it’s of use to anyone else, here’s my solution…
add_filter('woocommerce_coupon_get_discount_amount', 'woocommerce_discount_from_the_original_price', 10, 5 ); function woocommerce_discount_from_the_original_price( $discount, $discounting_amount, $cart_item, $single, $coupon ) { if ($coupon->discount_type == 'percent' && $coupon->code == 'staff502019') { $discount_percentage = $coupon->amount / 100; $item = wc_get_product($cart_item['product_id']); if ($item) { // // example product is £100 down to £66.66 // example discount is 50% // if ( $item->is_type( 'simple' ) ) { $sale_price = $item->sale_price; $regular_price = $item->regular_price; //echo '<p>Simple | Regualr Price: £' . $regular_price . ' | Sale Price: £' . $sale_price . '</p>'; if ( ($sale_price && $regular_price) && ($sale_price !== $regular_price) ) { $discount_from_regular_price = $regular_price * $discount_percentage; // e.g. £100 * 0.5 = £50 $discount = $discounting_amount - ($discount_from_regular_price * $cart_item['quantity']); // e.g. £66.66 - (£50 x 1) = £16.66 } } elseif ( $item->is_type( 'variable' ) ) { $variable_product = new WC_Product_Variation( $cart_item["variation_id"] ); $sale_price = $variable_product->sale_price; $regular_price = $variable_product->regular_price; //echo '<p>Variable | Regualr Price: £' . $regular_price . ' | Sale Price: £' . $sale_price . '</p>'; if ( ($sale_price && $regular_price) && ($sale_price !== $regular_price) ) { $discount_from_regular_price = $regular_price * $discount_percentage; $discount = $discounting_amount - ($discount_from_regular_price * $cart_item['quantity']); } } } } return $discount; }
Forum: Plugins
In reply to: [WooCommerce Extended Coupon Features FREE] Discount on original priceIs there any documentation out there which may point me in the right direction?
Forum: Reviews
In reply to: [SagePay Server Gateway for WooCommerce] Not workingI had the same issue, uninstalled it in the end
Viewing 3 replies - 1 through 3 (of 3 total)