• Resolved michaelw90

    (@michaelw90)


    We had an issue where the stock location was not actually being changed when updating location through the cart selection. We made a change to the update_cart_stock_locations() function (line 241 in src/classes/frontend/class-slw-frontend-cart.php). This ensures the new value is added to the cart session instead of reusing the old one.

    Could you add this to the next update:

    public function update_cart_stock_locations()
    {
    	// Do a nonce check
    	if( ! isset($_POST['cart_id']) || ! isset( $_POST['security'] ) || ! wp_verify_nonce( $_POST['security'], 'woocommerce-cart' ) ) {
    		wp_send_json( array( 'nonce_fail' => 1 ) );
    		exit;
    	}
    	// Save the stock locations to the cart meta
    	$cart = WC()->cart->cart_contents;
    	$cart_id = $_POST['cart_id'];
    	$stock_location = sanitize_slw_data($_POST['stock_location']);
    	$cart_item = $cart[$cart_id];
    	$cart_item['stock_location'] = $stock_location;
    
            // START CHANGE HERE
    	$cart[$cart_id] = $cart_item;
    	WC()->cart->set_cart_contents($cart);
            // END CHANGE HERE
    
    	WC()->cart->set_session();
    	wp_send_json( array( 'success' => 1 ) );
    	exit;
    }
    • This topic was modified 1 year, 10 months ago by michaelw90.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Product Location not actually updated in cart’ is closed to new replies.