• Resolved moultrex

    (@moultrex)


    Hello.

    We use your plugin. Everything works fine.

    We try to make a custom php script that want to get the Stock location and quantity of the product programmatically in the cart

    From the $_product = WC()->cart->get_cart();

    if we print_r the $_product in the array we can’t find the values.

    Is there any way programmatically to get them from the meta of the product?

    Thank you.

Viewing 1 replies (of 1 total)
  • Plugin Contributor alexmigf

    (@alexmigf)

    Hello @moultrex

    Please try this instead:

    $cart_items = WC()->cart->get_cart();
    foreach($cart_items as $cart_item_id => $cart_item) { 
    	$product_id = $cart_item['variation_id'] != 0 ? $cart_item['variation_id'] : $cart_item['product_id'];
    	if( !empty($product_id) ) {
    		$product_stock_locations = SlwStockAllocationHelper::getProductStockLocations( $product_id, true, null );
    		var_dump($product_stock_locations); // delete this
    	}
    }

    Let me know.

    • This reply was modified 4 years, 2 months ago by alexmigf.
    • This reply was modified 4 years, 2 months ago by alexmigf.
    • This reply was modified 4 years, 2 months ago by alexmigf.
Viewing 1 replies (of 1 total)
  • The topic ‘Get Stock Location Programmatically’ is closed to new replies.