SHARE
TWEET

Untitled

a guest Aug 20th, 2019 52 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. function cstr_add_cart_item_data( $cart_item_data, $product_id ) {
  4.     if ( isset( $_POST ) && ! empty( $product_id ) ) {
  5.         $post_data = $_POST;
  6.     } else {
  7.         return;
  8.     }
  9.    
  10.     if ( empty( $cart_item_data['my_field'] ) ) {
  11.         $cart_item_data['my_field'] = array();
  12.     }
  13.    
  14.     // add my data.
  15.    
  16.     return $cart_item_data;
  17. }
  18.  
  19. // Add item data to the cart.
  20. add_filter( 'woocommerce_add_cart_item_data', 'cstr_add_cart_item_data', 10, 2 );
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top