New Instance new WC_Cart

Viewed 17

I am adding a woocommerce product to simulate the shipping price based on parameters $_GET

This works however the cart replaces the customer's actual products.

I want to create a new dummy instance just to check is this possible?

This would be my current code.

$qty = 1;
$cart = new WC_Cart();
$cart->add_to_cart($_GET["product_id"], $qty);

As you can see the code is simple add a product to the cart.

I need this to be unaffected by the actual customer and be something like cart 2 that is not visible to the customer. That it only serves to verify and is eliminated once verified.

Any ideas to do it?

0 Answers
Related