Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function custom_add_products_to_cart(){
- WC()->cart->empty_cart();
- $request_body = file_get_contents('php://input');
- $decoded = json_decode($request_body);
- $cartElements = $decoded->addToCart;
- foreach ( $cartElements as $product_id ) {
- WC()->cart->add_to_cart( $product_id );
- }
- if ( $decoded->Uid ) {
- WC()->session->set( 'uid', $decoded->Uid );
- }
- die();
- };
Add Comment
Please, Sign In to add comment