Skip to content

Instantly share code, notes, and snippets.

@plugin-republic
Created December 6, 2018 12:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save plugin-republic/525acbfc37d91e97091c6823229a1aa3 to your computer and use it in GitHub Desktop.
Save plugin-republic/525acbfc37d91e97091c6823229a1aa3 to your computer and use it in GitHub Desktop.
<?php
function prefix_update_existing_cart_item_meta() {
$cart = WC()->cart->cart_contents;
foreach( $cart as $cart_item_id=>$cart_item ) {
$cart_item['new_meta_data'] = 'Your stuff goes here';
WC()->cart->cart_contents[$cart_item_id] = $cart_item;
}
WC()->cart->set_session();
}
@ahmedzeidan
Copy link

Thanks @CUBICinfinity i will give this a try and update back here for feedback if any... stay awesome...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment