RuleAdditionalCostFactory.php
1 week ago
RuleAdditionalCostFieldsFactory.php
1 week ago
RuleCostFieldsFactory.php
1 week ago
RuleCostFieldsFactory.php
58 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Class RuleCostFactory |
| 4 | * |
| 5 | * @package WPDesk\FS\TableRate\Rule\Cost |
| 6 | */ |
| 7 | |
| 8 | namespace WPDesk\FS\TableRate\Rule\Cost; |
| 9 | |
| 10 | use FSVendor\WPDesk\Forms\FieldProvider; |
| 11 | use FSVendor\WPDesk\Forms\Field; |
| 12 | use FSVendor\WPDesk\Forms\Renderer\JsonNormalizedRenderer; |
| 13 | |
| 14 | /** |
| 15 | * Can create costs fields. |
| 16 | */ |
| 17 | class RuleCostFieldsFactory implements FieldProvider { |
| 18 | |
| 19 | const COST_PER_ORDER = 'cost_per_order'; |
| 20 | |
| 21 | /** |
| 22 | * @return Field[] |
| 23 | */ |
| 24 | public function get_fields() { |
| 25 | return apply_filters( 'flexible_shipping_rule_cost_fields', $this->get_built_in_rule_cost_fields() ); |
| 26 | } |
| 27 | |
| 28 | /** |
| 29 | * . |
| 30 | * |
| 31 | * @return array |
| 32 | */ |
| 33 | public function get_normalized_cost_fields() { |
| 34 | $normalized_cost_fields = array(); |
| 35 | $renderer = new JsonNormalizedRenderer(); |
| 36 | |
| 37 | return $renderer->render_fields( $this, array() ); |
| 38 | } |
| 39 | |
| 40 | /** |
| 41 | * @return Field[] |
| 42 | */ |
| 43 | public function get_built_in_rule_cost_fields() { |
| 44 | return array( |
| 45 | ( new Field\InputNumberField() ) |
| 46 | ->set_name( self::COST_PER_ORDER ) |
| 47 | ->add_class( 'wc_input_decimal' ) |
| 48 | ->add_class( 'hs-beacon-search' ) |
| 49 | ->add_class( 'cost_per_order' ) |
| 50 | ->add_data( 'beacon_search', __( 'Cost per order', 'flexible-shipping' ) ) |
| 51 | ->set_label( __( 'rule cost is', 'flexible-shipping' ) ) |
| 52 | ->set_description_tip( __( 'Enter shipment cost for this rule.', 'flexible-shipping' ) ) |
| 53 | ->add_data( 'suffix', get_woocommerce_currency_symbol() ), |
| 54 | ); |
| 55 | } |
| 56 | |
| 57 | } |
| 58 |