• Hi. Would it be possible to add coupon or discount in WPC Share Cart? Customer share cart to me, I would like to add 5% discount and re-share to him, so he could see product prices with discount.

    Second thing is it possible to show final price of the whole shared cart?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Unfortunately they don’t have a github site to create a pull request, but I wrote a small snippet that adds the discount codes which were applied before. Just add this to your functions.php of your child-theme.

    add_action( 'wp', 'shared_cart', 100 );
    public function shared_cart() {
    		if ( isset( $_POST['wpcss-action'], $_POST['wpcss-key'], $_POST['wpcss-nonce'] ) ) {
    			if ( ! wp_verify_nonce( sanitize_key( $_POST['wpcss-nonce'] ), 'wpcss_add_products' ) ) {
    				print 'Permissions check failed.';
    				exit;
    			}
    		}
    
    		$saved_cart = get_option( 'wpcss_cart_' . sanitize_key( $_POST['wpcss-key'] ) );
    		if ( empty( $saved_cart['coupons'] ) ) {
    			return;
    		}
    
    		foreach ( $saved_cart['coupons'] as $coupon ) {
    			WC()->cart->add_discount( $coupon );
    		}
    	}
    
    Thread Starter vievioor

    (@vievioor)

    Thank you for help, but unfortunately your code makes critical error in my website.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Coupon, discount + final price’ is closed to new replies.