Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action( 'wpcf7_init', 'wpcf7_add_form_tag_orderno' );
- function wpcf7_add_form_tag_orderno() {
- wpcf7_add_form_tag( array( 'orderno', 'orderno*' ),
- 'wpcf7_orderno_form_tag_handler', array()
- );
- }
- function wpcf7_orderno_form_tag_handler( $tag ) {
- $customer_orders = get_posts( apply_filters( 'woocommerce_my_account_my_orders_query', array(
- 'numberposts' => $order_count,
- 'meta_key' => '_customer_user',
- 'meta_value' => get_current_user_id(),
- 'post_type' => wc_get_order_types( 'view-orders' ),
- 'post_status' => array_keys( wc_get_order_statuses() ),
- ) ) );
- if ( $customer_orders ) {
- $atts = array();
- $atts['class'] = $tag->get_class_option( $class );
- $atts['id'] = $tag->get_id_option();
- $atts['tabindex'] = $tag->get_option( 'tabindex', 'int', true );
- $atts['name'] = $tag->name;
- $atts = wpcf7_format_atts( $atts );
- echo '<select name="orderno">';
- echo '<option>'.__( "Numéro de la commande", "sinope" ).'</option>';
- foreach ( $customer_orders as $customer_order ) {
- $order = wc_get_order( $customer_order );
- $item_count = $order->get_item_count();
- echo '
- <option value="'.$order->get_order_number().'">'.$order->get_order_number().'</option>
- ';
- }
- echo '</select>';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement