Guest User

Untitled

a guest
Oct 21st, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. function custom_add_products_to_cart(){
  2. WC()->cart->empty_cart();
  3. $request_body = file_get_contents('php://input');
  4. $decoded = json_decode($request_body);
  5. $cartElements = $decoded->addToCart;
  6. foreach ( $cartElements as $product_id ) {
  7. WC()->cart->add_to_cart( $product_id );
  8. }
  9. if ( $decoded->Uid ) {
  10. WC()->session->set( 'uid', $decoded->Uid );
  11. }
  12. die();
  13. };
Add Comment
Please, Sign In to add comment