0
0
001alena0012020-06-05 14:45:44
WordPress
001alena001, 2020-06-05 14:45:44

How to sort the items in the cart by a custom field?

Hello, there is a code:

<?php global $woocommerce;
$items = $woocommerce->cart->get_cart();
foreach($items as $item => $values) {
$_product = wc_get_product( $values['data']->get_id());
$id = $_product->get_id();
?>
// content-product.php
<?php }?>

With this code, I display the products that are currently in the cart.
I need to sort them by an arbitrary field, an arbitrary field has a numeric value.
I tried to insert arguments, but the loop does not react to them. Or if there is an option to sort the goods in the basket itself by an arbitrary field - it will do too!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question