Advertisement
Guest User

Untitled

a guest
Aug 1st, 2017
316
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.30 KB | None | 0 0
  1. add_action( 'wpcf7_init', 'wpcf7_add_form_tag_orderno' );
  2. function wpcf7_add_form_tag_orderno() {
  3.     wpcf7_add_form_tag( array( 'orderno', 'orderno*' ),
  4.         'wpcf7_orderno_form_tag_handler', array()
  5.     );
  6. }
  7. function wpcf7_orderno_form_tag_handler( $tag ) {
  8.  
  9.     $customer_orders = get_posts( apply_filters( 'woocommerce_my_account_my_orders_query', array(
  10.         'numberposts' => $order_count,
  11.         'meta_key'    => '_customer_user',
  12.         'meta_value'  => get_current_user_id(),
  13.         'post_type'   => wc_get_order_types( 'view-orders' ),
  14.         'post_status' => array_keys( wc_get_order_statuses() ),
  15.     ) ) );
  16.  
  17.     if ( $customer_orders ) {
  18.         $atts = array();
  19.         $atts['class'] = $tag->get_class_option( $class );
  20.         $atts['id'] = $tag->get_id_option();
  21.         $atts['tabindex'] = $tag->get_option( 'tabindex', 'int', true );
  22.         $atts['name'] = $tag->name;
  23.         $atts = wpcf7_format_atts( $atts );
  24.         echo '<select name="orderno">';
  25.         echo '<option>'.__( "Numéro de la commande", "sinope" ).'</option>';
  26.         foreach ( $customer_orders as $customer_order ) {
  27.             $order      = wc_get_order( $customer_order );
  28.             $item_count = $order->get_item_count();
  29.             echo '
  30.                 <option value="'.$order->get_order_number().'">'.$order->get_order_number().'</option>
  31.             ';
  32.         }
  33.         echo '</select>';
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement