Repository Forums Support WooCommerce Extended Coupon Features PRO Free product choice in combination with Advanced Dynamic Pricing For Woocommerc

Viewing 15 posts - 1 through 15 (of 20 total)
  • Author
    Posts
  • #15517
    Bart van Doveren
    Participant

    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,
    Bart

    #15518
    Soft79
    Keymaster

    Hi Bart, can you send me an url and steps to reproduce this behaviour on your site?

    #15519
    Bart van Doveren
    Participant

    Hi,

    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,
    Bart

    #15520
    Bart van Doveren
    Participant

    Note that if you see another solution for the extra packaging cost, I’m happy to give that a try.

    #15521
    Soft79
    Keymaster

    Weird, it is as if the Dynamic Pricing plugin voids the session data of our plugin. Can you enable Settings > Extended Coupon Features > Debug Mode ?

    #15522
    Bart van Doveren
    Participant

    It’s activated now

    #15523
    Soft79
    Keymaster

    Ok, nothing strange there. I need to investigate the session issue locally, you can disable debug.

    #15524
    Bart van Doveren
    Participant

    OK, just to avoid confusing customers for the moment but to allow you to check what happens: I have changed the min amount to 500

    #15525
    Soft79
    Keymaster

    The 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);
    
    #15526
    Bart van Doveren
    Participant

    Thanks! 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?

    #15528
    Bart van Doveren
    Participant

    Another thing that goes wrong: the free product is not added for free, normal price is applied in the cart

    #15529
    Soft79
    Keymaster

    Replace 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

    #15530
    Bart van Doveren
    Participant

    New 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

    #15531
    Soft79
    Keymaster

    I 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.

    #15532
    Bart van Doveren
    Participant

    That filter prevents the free product from being added to the cart as well…

Viewing 15 posts - 1 through 15 (of 20 total)
  • You must be logged in to reply to this topic.