Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?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 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement