Last active
August 8, 2019 14:19
-
-
Save rcstr/f72c8dff0faa0910068b813b509b6d77 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function cstr_add_cart_item_data( $cart_item_data, $product_id ) { | |
if ( isset( $_POST ) && ! empty( $product_id ) ) { | |
$post_data = $_POST; | |
} else { | |
return; | |
} | |
if ( empty( $cart_item_data['my_field'] ) ) { | |
$cart_item_data['my_field'] = array(); | |
} | |
// add my data. | |
return $cart_item_data; | |
} | |
// Add item data to the cart. | |
add_filter( 'woocommerce_add_cart_item_data', 'cstr_add_cart_item_data', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment