איך להוסיף שדות לעמוד לתשלום בווקומרס
אנחנו נוסיף 3 שדות – אפשר כמובן להגדיל את מספר השדות
אלו השדות:
- Branch (סניף)
- City (עיר)
- Custom order id (מזהה הזמנה יחודי)
הוספת השדות בעמוד לתשלום ובעמוד סיכומי ההזמנות
// Hook in add_filter( 'woocommerce_checkout_fields' , 'pablos_override_checkout_branch' ); add_filter( 'woocommerce_checkout_fields' , 'pablos_override_checkout_ccity' ); add_filter( 'woocommerce_checkout_fields' , 'pablos_override_checkout_ordern' ); // Our hook in functions – $branch and the other filters as in the passed filters function pablos_override_checkout_branch( $branch ) { $branch['shipping']['shipping_branch'] = array( 'label' => __('Branch', 'woocommerce'), 'placeholder' => _x('branch', 'placeholder', 'woocommerce'), 'required' => false, 'class' => array('form-row-wide'), 'clear' => true ); return $branch; }, function pablos_override_checkout_city( $ccity ) { $ccity['shipping']['shipping_ccity'] = array( 'label' => __('City', 'woocommerce'), 'placeholder' => _x('ccity', 'placeholder', 'woocommerce'), 'required' => false, 'class' => array('form-row-wide'), 'clear' => true ); return $ccity; }, function pablos_override_checkout_ordern( $ordern ) { $ordern['shipping']['shipping_ordern'] = array( 'label' => __('Order Custom Number', 'woocommerce'), 'placeholder' => _x('order_custom_number', 'placeholder', 'woocommerce'), 'required' => false, 'class' => array('form-row-wide'), 'clear' => true ); return $ordern; } /** * Display fields on the order edit page */ /** * Display field values on the order edit page */ add_action( 'woocommerce_admin_order_data_after_shipping_address', 'branch_display_admin_order_meta', 10, 1 ); function branch_display_admin_order_meta($order){ echo '<p><strong>'.__('Branch From Checkout Forms').':</strong> ' . get_post_meta( $order->get_id(), '_shipping_branch', true ) . '</p>'; }, add_action( 'woocommerce_admin_order_data_after_shipping_address', 'ccity_display_admin_order_meta', 10, 1 ); function ccity_display_admin_order_meta($order){ echo '<p><strong>'.__('City From The Checkout Forms').':</strong> ' . get_post_meta( $order->get_id(), '_shipping_ccity', true ) . '</p>'; }, add_action( 'woocommerce_admin_order_data_after_shipping_address', 'ordern_display_admin_order_meta', 10, 1 ); function ordern_display_admin_order_meta($order){ echo '<p><strong>'.__('Oder Custom id From Checkout Forms').':</strong> ' . get_post_meta( $order->get_id(), '_shipping_ordern', true ) . '</p>'; }