Repository Forums Support WooCommerce Extended Coupon Features PRO Adding Items to Cart After Coupon is applied sometimes works

Topic Resolution: Resolved
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #124
    kevin.quach
    Participant

    Hi Soft79,

    Thanks again for the awesome plugin. I have some odd behaviours that I’m trying to figure out with my website’s implementation of it.

    The process works by users clicking on a link http://friendshipsocks.com/shop/welcome?apply_coupon=(coupon code). The woocommerce message box does appear and states the coupon has been applied because we’ve masked a product details page to be the welcome page in order to meet the requirement of the plugin only applying on woocommerce pages. However, after the user makes their way to the shop page, pick a sock and add it to their cart, it doesn’t seem the coupon has applied even though it stated it did.

    The real weird behaviour we’ve noticed is that when we then redo this exact process a second time, it then works. The coupon is applied to the item we put on the cart.

    Perhaps it has something to do with adding items after the coupon has applied? Or the cart isn’t being updated?

    Let me know if you need additional information. You can gain access to the page here:

    http://friendshipsocks.com

    password to get past the lock screen: bestgiftever

    Kevin Quach

    #125
    Soft79
    Keymaster

    Hi Kevin,

    please try replacing the coupon_by_url function in includes/wjecf-autocoupon.php with the following:

    
    public function coupon_by_url() {
        if ( ! $this->_executed_coupon_by_url && isset( $_GET['apply_coupon'] ) ) {
            $this->_executed_coupon_by_url = true;
            $split = explode( ",", $_GET['apply_coupon'] );
            if( ! WC()->session->has_session() )
            {
                WC()->session->set_customer_session_cookie( true );
            }            
    
            $cart = WC()->cart;
            foreach ( $split as $coupon_code ) {
                $cart->add_discount( $coupon_code );
            }
        }
    }
    

    Will that work for you? I will fix this in a future release.

    #128
    kevin.quach
    Participant

    Yeah, I replaced the function with that snippet and it seems to work perfectly now. I guess it was an issue with the session.

    Thanks for the quick solution, I appreciate it!

    Kevin Quach

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