• Resolved S3Bubble

    (@s3bubble)


    Hi All,

    I am trying to switch a product within the cart but when i remove a product and switch it with the new one it still applies a discount code if applied.

    I see in the code api you have shopp_add_cart_discount_code is there also a option to shopp_rmv_cart_discount_code?

    For instance if i run the code below and i have a discount code 20% off it will applied that percentage on top of my subscription trial period of the product it switches to i really need to remove the discount all together and switch to the other product.

    Full code.

    function shopp_switch_product () {
    
        // Get discount code
        $discount = trim(strtolower($_REQUEST['discount']));
    
        if($discount == 'discover10'){
    
            $item = shopp('cart','lastitem','return=true');
    
            shopp_rmv_cart_item($item->_id);
    
            // get my product
            $Product = shopp_product('Classic - Subscription (10% off)', 'name');
    
            // Add quantity 2 of My Product to the cart
            shopp_add_cart_product($Product->id, 1);;
    
        }
    
    }
    add_action('shopp_cart_request', 'shopp_switch_product');

    Thanks

    https://wordpress.org/plugins/shopp/

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Removing a discount code’ is closed to new replies.