• Hi everyone
    I’m working on one client site, the previous developer uses custom post type build like a product collection page, kind like woo commerce, but only can add to cart to request a quote to the company, no transaction on the cart application.

    I have trouble with I can add to cart is fine, but when I view the cart page. the item won’t show up unless I refresh the page. same problem with delete item in the cart.

    Does it have anyway, it will auto refresh when action trigger?

    There’s a cookie set on the page, thinking might be the issue.

    Thank you so much for the help!

    —– code ———-

    <?php
        if(get_query_var('remove') > 0){
    	  $r = get_query_var('remove');
    	  $d = get_query_var('d');
    	  if (isset($_COOKIE['cart'])) {
    		$cart = json_decode(base64_decode($_COOKIE['cart']), true);
    		unset($cart[$r][$d]);
    		if(empty($cart[$r])){
    			unset($cart[$r]);
    		}
    		if(empty($cart)){
    			setcookie("cart", base64_encode(json_encode($cart)), time() - 3600, '/');
    		} else {
    			setcookie("cart", base64_encode(json_encode($cart)), time() + 2592000, '/');
    		}
    		header('Location: '.get_the_permalink());
    		die();
    	} else {
    		header('Location: '.get_the_permalink());
    		die();
    	}
     } 
Viewing 3 replies - 1 through 3 (of 3 total)
  • Sorry, carts are not a part of WordPress. If you are using an eCommerce platform please visit the developers of that plugin/platform fro help with their code.

    Thread Starter madebymt

    (@madebymt)

    @jaycbrf
    Thank you for your responding.
    It uses WP function create custom post type and writing PHP function to add an item to the cart page, it’s not from the third-party plugin. (It does have the advance custom field for product info to display.)

    If anyone has any suggestion please let me know.
    Big Thanks!

    Again, the problem here is not with WordPress. Please seek support with the plugin developer.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘custom post to cart won’t update (cookie issue)’ is closed to new replies.