__('Shipping', 'formipay'), 'fields' => $shipping_settings ); } return $fields; } public function add_form_shipping_menu($fields) { $shipping_methods = apply_filters( 'formipay/product-settings/tab:shipping/method', [ 'free_shipping' => [ 'method' => __( 'Free Shipping', 'formipay' ) ] ] ); $shipping_options = []; $shipping_fields = []; foreach($shipping_methods as $id => $shipping){ // $id = $shipping['id']; $label = $shipping['method']; if(isset($shipping['courier'])){ $label .= ' - '.$shipping['courier']; if(isset($shipping['service'])){ $label .= ' - '.$shipping['service']; } } $shipping_options[$id] = $label; } $shipping_fields = [ 'shipping_notice' => array( 'type' => 'notification_message', 'image' => FORMIPAY_URL . 'admin/assets/img/logistics.png', 'description' => __( '

No Shipping Method Available

Shipping methods only for physical product type. If you insist to use shipping method, change your product type first

', 'formipay' ), 'dependency' => array( 'key' => 'product_type', 'value' => 'digital', 'section' => 'general' ), ), 'shipping_method' => array( 'type' => 'radio', 'label' => esc_html__('Shipping Methods', 'formipay'), 'options' => $shipping_options, 'dependency' => array( 'key' => 'product_type', 'value' => 'physical', 'section' => 'general' ), ) ]; $free_shipping_fields = array( 'free_shipping_group' => array( 'type' => 'group_title', 'label' => __( 'Free Shipping Setup', 'formipay' ), 'description' => __( 'Will not add any shipping fee to the order', 'formipay' ), 'dependency' => array( array( 'key' => 'product_type', 'value' => 'physical', 'section' => 'general' ), array( 'key' => 'shipping_method', 'value' => 'free_shipping' ) ), 'dependencies' => '&&', 'group' => 'started' ), 'free_shipping_label' => array( 'type' => 'text', 'label' => __( 'Label', 'formipay' ), 'value' => __( 'Free Shipping', 'formipay' ), 'dependency' => array( array( 'key' => 'product_type', 'value' => 'physical', 'section' => 'general' ), array( 'key' => 'shipping_method', 'value' => 'free_shipping' ) ), 'dependencies' => '&&', ), 'free_shipping_add_to_order_review' => array( 'type' => 'checkbox', 'label' => __( 'Show in Order Review', 'formipay' ), 'dependency' => array( array( 'key' => 'product_type', 'value' => 'physical', 'section' => 'general' ), array( 'key' => 'shipping_method', 'value' => 'free_shipping' ) ), 'dependencies' => '&&', 'group' => 'ended' ), ); foreach($free_shipping_fields as $key => $value) { $shipping_fields[$key] = $value; } $shipping_fields = apply_filters( 'formipay/product-settings/tab:shipping', $shipping_fields ); if(!empty($shipping_fields)){ $fields['formipay_product_settings']['shipping'] = array( 'name' => __( 'Shipping', 'formipay' ), 'fields' => $shipping_fields ); } return $fields; } }