I have develop shoping cart in wordpress using Woocommerce plugin. I need to display products in the cart order by product price please help me to do this
thanks
I have develop shoping cart in wordpress using Woocommerce plugin. I need to display products in the cart order by product price please help me to do this
thanks
You must be logged in to post a comment.
To order products low to high or high to low price in the Woocommerce cart, try adding the following to your functions.php file (or plugin):
This function is similar and derived from one seen at https://businessbloomer.com/woocommerce-sort-cart-items-alphabetically-az/ which is nearly identical to this earlier-posted function: https://gist.github.com/maxrice/6541634
In most cases, for manipulating data on the WordPress ecosystem, the answer will be
wp filter
, nowp action
.In addition,
WC_car.cart_contents
array, hold the product object it’s self on$cart_contents['data']; //WC_Product_Object
, So we didn’t need to get product again.Simple filter to order by price:
PHP 7.4+
PHP < 7
mmmm, Is right there on the Woo admin page!!
Woocommerce – > Adjustments – > Catalogue – > Default Products Ordering