Cart discounts display incorrect value for BOGO
-
Refer to the image url attached below, discount entitle should be at RM6 but at the discount display as RM12.
May I know how to solve this?Screenshot 2024-06-07 151108.png – Google Drive
The page I need help with: [log in to see the link]
-
Hi @devopswb ,
Greetings from WebToffee Support!
Thanks for reaching out to us regarding the issue you are experiencing. We were unable to replicate the same issue on our end. It appears that the issue may be caused by a third-party plugin conflict or a theme conflict. In order to troubleshoot the issue, please follow the below steps:
- Deactivate all plugins except Smart Coupons for WooCommerce and WooCommerce. Check if the issue persists after deactivating other plugins.
- If the issue persists, switch to any of the default WooCommerce themes like Storefront temporarily and check if the issue persists.
- If the issue doesn’t persist after deactivating other plugins, activate each plugin one by one and check when the issue reappears.
Additionally, please provide screenshots of the coupon edit pages of the coupon you have created. Also, provide the WooCommerce System Status report. You can access the System Status report in WooCommerce by navigating to WooCommerce -> Status -> Get system status report.
If you have any privacy concerns, you may share the required information through this link.
Once we have this information, we’ll be better equipped to assist you further.
Hi,
Thank you for the reply.
I tried to use Storefront theme and is showing correct discount value. Is there any workaround for theme conflict?
Hi @devopswb ,
Thanks for carrying out the troubleshooting steps and identifying that the issue is related to a theme conflict. To assist you further, kindly provide the details of the theme you are using.
Additionally, share screenshots of the coupon edit pages of the coupon you have created. Ensure to include screenshots of all the tabs in the coupon settings so that we can replicate the issue on our end.
With these details, we’ll be able to investigate the problem more effectively.
Hi,
Please refer the url below for information needed.
https://drive.google.com/drive/folders/1zXVNc3HcQLBJewTgCYyrBl8P14q_slI5?usp=sharing
Hi @devopswb,
Thank you for sharing the information. Upon reviewing the details provided, it appears that you are using a child theme of the Divi theme. In order for us to replicate the issue on our end and thoroughly investigate it, we require the child theme files.
Could you please provide us with the child theme files so that we can proceed with our investigation? You can zip the theme directory and share via this link.
Looking forward to your response.
Hi @devopswb ,
To resolve the theme compatibility issue you have experienced, please add the following code snippet to your active theme’s functions.php file (WordPress Dashboard > Appearance > Theme Editor > functions.php), or you can use a Code Snippet plugin for easier implementation.
<span style="font-size: 12.8px;">add_filter('woocommerce_coupon_discount_amount_html', function($discount_amount_html, $coupon) {
if (
class_exists('Wt_Smart_Coupon_Giveaway_Product_Public') &&
method_exists('Wt_Smart_Coupon_Giveaway_Product_Public', 'is_bogo') &&
method_exists('Wt_Smart_Coupon_Giveaway_Product_Public', 'get_product_price') &&
method_exists('Wt_Smart_Coupon_Giveaway_Product_Public', 'get_product_giveaway_data') &&
method_exists('Wt_Smart_Coupon_Giveaway_Product_Public', 'get_available_discount_for_giveaway_product') &&
Wt_Smart_Coupon_Giveaway_Product_Public::is_bogo($coupon)
) {
$amount = 0;
foreach (WC()->cart->get_cart() as $cart_item_key => $cart_item) {
if (
isset($cart_item['free_product']) &&
'wt_give_away_product' === $cart_item['free_product'] &&
$cart_item['free_gift_coupon'] === $coupon->get_code()
) {
$item_id = ($cart_item['variation_id'] > 0) ? $cart_item['variation_id'] : $cart_item['product_id'];
$product = wc_get_product($item_id);
$product_price = Wt_Smart_Coupon_Giveaway_Product_Public::get_product_price($product);
$wt_smart_coupon_instance = Wt_Smart_Coupon_Giveaway_Product_Public::get_instance();
$giveaway_data = $wt_smart_coupon_instance->get_product_giveaway_data($item_id, $coupon->get_code(), $cart_item);
$discount = Wt_Smart_Coupon_Giveaway_Product_Public::get_available_discount_for_giveaway_product($product, $giveaway_data);
$discount = $discount * $cart_item['quantity'];
$amount += $discount;
}
}
return wc_price($amount);
}
return $discount_amount_html;
}, 101, 2);</span>Kindly try out the code snippet and let us know how it goes.
Hi @devopswb ,
We hope the theme conflict you experienced is rectified after using the code snippet we shared. As this thread has been inactive for a while, we are marking it as resolved.
If you require any further assistance, please feel free to create a new thread.
- You must be logged in to reply to this topic.