Advertisement
verygoodplugins

Untitled

Mar 17th, 2020
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.65 KB | None | 0 0
  1. function wpf_product_meta_fields( $fields ) {
  2.  
  3.     $fields['course_date'] = array( 'label' => 'Course Date', 'type' => 'date', 'group' => 'woocommerce' );
  4.  
  5.     return $fields;
  6.  
  7. }
  8.  
  9. add_filter( 'wpf_meta_fields', 'wpf_product_meta_fields' );
  10.  
  11. function get_product_data( $order_data, $order ) {
  12.  
  13.     foreach ( $order->get_items() as $item ) {
  14.  
  15.         $product_id = $item->get_product_id();
  16.  
  17.         $meta_value = get_post_meta( $product_id, 'acls-p-course-date-a', true );
  18.  
  19.         if ( ! empty( $meta_value ) ) {
  20.             $order_data['course_date'] = $meta_value;
  21.         }
  22.     }
  23.  
  24.     return $order_data;
  25.  
  26. }
  27. add_filter( 'wpf_woocommerce_customer_data', 'get_product_data', 10, 2 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement