Repository › Forums › Support › WooCommerce Extended Coupon Features PRO › Free product choice in combination with Advanced Dynamic Pricing For Woocommerc
- This topic has 19 replies, 2 voices, and was last updated 3 years, 11 months ago by Bart van Doveren.
-
AuthorPosts
-
May 1, 2020 at 10:25 am #15517Bart van DoverenParticipant
Hi,
just purchased the plugin. Love the simplicity and integration, but have one major issue:
I have also the “Advanced Dynamic Pricing For Woocommerce” for a specific purpose: add a fixed cost for specific products (for returnable packaging). When a product to which this price rule applies is added, the free products added by this plugin do not appear anymore.Any suggestion how to solve? If there is another way to add the fixed cost, that would work for me as well (eg. a negative fixed price discount coupon for each item from a specific category?)
Many thanks,
BartMay 1, 2020 at 10:37 am #15518Soft79KeymasterHi Bart, can you send me an url and steps to reproduce this behaviour on your site?
May 1, 2020 at 10:45 am #15519Bart van DoverenParticipantHi,
try to add the products in this list to the cart: https://estrellaindal.es/lista-deseos/view/CHPSGSQZB1TS/
The beer will trigger an extra cost for the packaging with the other plugin.
If you add for €50, the cupon for the free product will be added automically. You will see that it only works if you remove the beer.Please do not finalize the order as the site is live.
Thanks,
BartMay 1, 2020 at 10:47 am #15520Bart van DoverenParticipantNote that if you see another solution for the extra packaging cost, I’m happy to give that a try.
May 1, 2020 at 12:08 pm #15521Soft79KeymasterWeird, it is as if the Dynamic Pricing plugin voids the session data of our plugin. Can you enable Settings > Extended Coupon Features > Debug Mode ?
May 1, 2020 at 12:12 pm #15522Bart van DoverenParticipantIt’s activated now
May 1, 2020 at 12:21 pm #15523Soft79KeymasterOk, nothing strange there. I need to investigate the session issue locally, you can disable debug.
May 1, 2020 at 1:05 pm #15524Bart van DoverenParticipantOK, just to avoid confusing customers for the moment but to allow you to check what happens: I have changed the min amount to 500
May 1, 2020 at 1:38 pm #15525Soft79KeymasterThe advanced pricing plugins empties the cart and refills the cart whenever a rule applies. Our plugin ‘forgets’ the free product selection when the cart is emptied.
If you’re comfortable placing a small php snippet in your child theme, this will solve the issue:
add_action( 'init', function() { if ( ! is_callable( 'WJECF' ) ) return; $plugin = WJECF()->get_plugin('pro-free-products'); if ( ! $plugin ) return; remove_action( 'woocommerce_cart_emptied', array( $plugin, 'woocommerce_cart_emptied' ) ); }, 20);
May 1, 2020 at 2:08 pm #15526Bart van DoverenParticipantThanks! Now the free product stays indeed in the cart.
However, it seems that the customer can not remove the auto-cupon anymore. (Option “Check this box to allow the customer to remove ‘Auto Coupons’ from the cart.” activated).
What does the code exactly do? It removes some action from the plugin when the cart is emptied, right?
May 1, 2020 at 2:29 pm #15528Bart van DoverenParticipantAnother thing that goes wrong: the free product is not added for free, normal price is applied in the cart
May 1, 2020 at 2:36 pm #15529Soft79KeymasterReplace the snippet with:
/** * Fix for advanced pricing rules plugin, which empties and recreates the cart when a rule applies */ add_action( 'init', function() { if ( ! is_callable( 'WJECF' ) ) return; if ( $plugin = WJECF()->get_plugin('pro-free-products') ) { remove_action( 'woocommerce_cart_emptied', array( $plugin, 'woocommerce_cart_emptied' ) ); } if ( $plugin = WJECF()->get_plugin('autocoupon') ) { remove_action( 'woocommerce_cart_emptied', array( $plugin, 'action_cart_emptied' ), 10, 0 ); } }, 20);
This snippet disables actions of our plugin that are performed when the cart gets emptied. By default our plugin must forget coupon info when the cart is emptied.
Can you show me how/where the product gets a price? I see this: https://imgur.com/NvFHARL
May 1, 2020 at 2:49 pm #15530Bart van DoverenParticipantNew code indeed allows removing coupon again.
The normal price of the free item gets added to the cart subtotal: see here: https://imgur.com/a/dL25QTX
May 1, 2020 at 3:08 pm #15531Soft79KeymasterI see, it looks like the plugin has a filter for that also:
add_filter( 'wdp_skip_cart_item', function( $skip, $cart_item, $product ) { if ( isset( $cart_item['_wjecf_free_product_coupon'] ) ) { $skip = true; } return $skip; }, 10, 3);
This will prevent the advanced pricing plugin from overwriting the price of a free gift.
May 1, 2020 at 3:15 pm #15532Bart van DoverenParticipantThat filter prevents the free product from being added to the cart as well…
-
AuthorPosts
- You must be logged in to reply to this topic.