Нет описания

settings-flat-rate.php 5.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <?php
  2. /**
  3. * Legacy flat rate settings.
  4. *
  5. * @package WooCommerce\Shipping
  6. */
  7. if ( ! defined( 'ABSPATH' ) ) {
  8. exit;
  9. }
  10. $cost_desc = __( 'Enter a cost (excl. tax) or sum, e.g. <code>10.00 * [qty]</code>.', 'woocommerce' ) . '<br/>' . __( 'Supports the following placeholders: <code>[qty]</code> = number of items, <code>[cost]</code> = cost of items, <code>[fee percent="10" min_fee="20"]</code> = Percentage based fee.', 'woocommerce' );
  11. /**
  12. * Settings for flat rate shipping.
  13. */
  14. $settings = array(
  15. 'enabled' => array(
  16. 'title' => __( 'Enable/Disable', 'woocommerce' ),
  17. 'type' => 'checkbox',
  18. 'label' => __( 'Once disabled, this legacy method will no longer be available.', 'woocommerce' ),
  19. 'default' => 'no',
  20. ),
  21. 'title' => array(
  22. 'title' => __( 'Method title', 'woocommerce' ),
  23. 'type' => 'text',
  24. 'description' => __( 'This controls the title which the user sees during checkout.', 'woocommerce' ),
  25. 'default' => __( 'Flat rate', 'woocommerce' ),
  26. 'desc_tip' => true,
  27. ),
  28. 'availability' => array(
  29. 'title' => __( 'Availability', 'woocommerce' ),
  30. 'type' => 'select',
  31. 'default' => 'all',
  32. 'class' => 'availability wc-enhanced-select',
  33. 'options' => array(
  34. 'all' => __( 'All allowed countries', 'woocommerce' ),
  35. 'specific' => __( 'Specific Countries', 'woocommerce' ),
  36. ),
  37. ),
  38. 'countries' => array(
  39. 'title' => __( 'Specific countries', 'woocommerce' ),
  40. 'type' => 'multiselect',
  41. 'class' => 'wc-enhanced-select',
  42. 'css' => 'width: 400px;',
  43. 'default' => '',
  44. 'options' => WC()->countries->get_shipping_countries(),
  45. 'custom_attributes' => array(
  46. 'data-placeholder' => __( 'Select some countries', 'woocommerce' ),
  47. ),
  48. ),
  49. 'tax_status' => array(
  50. 'title' => __( 'Tax status', 'woocommerce' ),
  51. 'type' => 'select',
  52. 'class' => 'wc-enhanced-select',
  53. 'default' => 'taxable',
  54. 'options' => array(
  55. 'taxable' => __( 'Taxable', 'woocommerce' ),
  56. 'none' => _x( 'None', 'Tax status', 'woocommerce' ),
  57. ),
  58. ),
  59. 'cost' => array(
  60. 'title' => __( 'Cost', 'woocommerce' ),
  61. 'type' => 'text',
  62. 'placeholder' => '',
  63. 'description' => $cost_desc,
  64. 'default' => '',
  65. 'desc_tip' => true,
  66. ),
  67. );
  68. $shipping_classes = WC()->shipping()->get_shipping_classes();
  69. if ( ! empty( $shipping_classes ) ) {
  70. $settings['class_costs'] = array(
  71. 'title' => __( 'Shipping class costs', 'woocommerce' ),
  72. 'type' => 'title',
  73. 'default' => '',
  74. /* translators: %s: Admin shipping settings URL */
  75. 'description' => sprintf( __( 'These costs can optionally be added based on the <a href="%s">product shipping class</a>.', 'woocommerce' ), admin_url( 'admin.php?page=wc-settings&tab=shipping&section=classes' ) ),
  76. );
  77. foreach ( $shipping_classes as $shipping_class ) {
  78. if ( ! isset( $shipping_class->term_id ) ) {
  79. continue;
  80. }
  81. $settings[ 'class_cost_' . $shipping_class->term_id ] = array(
  82. /* translators: %s: shipping class name */
  83. 'title' => sprintf( __( '"%s" shipping class cost', 'woocommerce' ), esc_html( $shipping_class->name ) ),
  84. 'type' => 'text',
  85. 'placeholder' => __( 'N/A', 'woocommerce' ),
  86. 'description' => $cost_desc,
  87. 'default' => $this->get_option( 'class_cost_' . $shipping_class->slug ), // Before 2.5.0, we used slug here which caused issues with long setting names.
  88. 'desc_tip' => true,
  89. );
  90. }
  91. $settings['no_class_cost'] = array(
  92. 'title' => __( 'No shipping class cost', 'woocommerce' ),
  93. 'type' => 'text',
  94. 'placeholder' => __( 'N/A', 'woocommerce' ),
  95. 'description' => $cost_desc,
  96. 'default' => '',
  97. 'desc_tip' => true,
  98. );
  99. $settings['type'] = array(
  100. 'title' => __( 'Calculation type', 'woocommerce' ),
  101. 'type' => 'select',
  102. 'class' => 'wc-enhanced-select',
  103. 'default' => 'class',
  104. 'options' => array(
  105. 'class' => __( 'Per class: Charge shipping for each shipping class individually', 'woocommerce' ),
  106. 'order' => __( 'Per order: Charge shipping for the most expensive shipping class', 'woocommerce' ),
  107. ),
  108. );
  109. }
  110. if ( apply_filters( 'woocommerce_enable_deprecated_additional_flat_rates', $this->get_option( 'options', false ) ) ) {
  111. $settings['additional_rates'] = array(
  112. 'title' => __( 'Additional rates', 'woocommerce' ),
  113. 'type' => 'title',
  114. 'default' => '',
  115. 'description' => __( 'These rates are extra shipping options with additional costs (based on the flat rate).', 'woocommerce' ),
  116. );
  117. $settings['options'] = array(
  118. 'title' => __( 'Additional rates', 'woocommerce' ),
  119. 'type' => 'textarea',
  120. 'description' => __( 'One per line: Option name | Additional cost [+- Percents] | Per cost type (order, class, or item) Example: <code>Priority mail | 6.95 [+ 0.2%] | order</code>.', 'woocommerce' ),
  121. 'default' => '',
  122. 'desc_tip' => true,
  123. 'placeholder' => __( 'Option name | Additional cost [+- Percents%] | Per cost type (order, class, or item)', 'woocommerce' ),
  124. );
  125. }
  126. return $settings;