Advertisement
verygoodplugins

Untitled

Nov 15th, 2019
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.60 KB | None | 0 0
  1. function wpf_save_custom_checkout_field( $order_id ) {
  2.  
  3.     if ( ! empty( $_POST['special-offers'] ) ) {
  4.         update_post_meta( $order_id, 'special-offers', true );
  5.     }
  6.  
  7. }
  8.  
  9. add_action( 'woocommerce_checkout_update_order_meta', 'wpf_save_custom_checkout_field' );
  10.  
  11. function get_product_data( $order_data, $order ) {
  12.  
  13.     $order_data['special-offers'] = get_post_meta( $order->get_id(), 'special-offers', true );
  14.  
  15.     if ( empty( $order_data['special-offers'] ) ) {
  16.         $order_data['special-offers'] = null;
  17.     }
  18.  
  19.     return $order_data;
  20.  
  21. }
  22.  
  23. add_filter( 'wpf_woocommerce_customer_data', 'get_product_data', 10, 2 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement