my code stock.com

vadim ansari

Woocommerce individual cart items
by vadim ansari

Snippet options

Download: Download snippet as woocommerce-individual-cart-items.html.
Copy snippet: For this you need a free my code stock.com account.
Embed code : You will find the embed code for this snippet at the end of the page, if you want to embed it into a website or a blog!

function force_individual_cart_items( $cart_item_data, $product_id ){

  $unique_cart_item_key = md5( microtime().rand() );
  $cart_item_data['unique_key'] = $unique_cart_item_key;

  return $cart_item_data;

}

add_filter( 'woocommerce_add_cart_item_data','force_individual_cart_items', 10, 2 );


/*
 * @desc Remove quantity selector in all product type
 */
function remove_all_quantity_fields( $return, $product ) {

    return true;

}

add_filter( 'woocommerce_is_sold_individually', 'remove_all_quantity_fields', 10, 2 );

Create a free my code stock.com account now.

my code stok.com is a free service, which allows you to save and manage code snippes of any kind and programming language. We provide many advantages for your daily work with code-snippets, also for your teamwork. Give it a try!

Find out more and register now

You can customize the height of iFrame-Codes as needed! You can find more infos in our API Reference for iframe Embeds.