Advertisement
Guest User

Untitled

a guest
Aug 20th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  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 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement