| 1 |
<?php |
| 2 |
|
| 3 |
namespace Sendy\WooCommerce\ShippingMethods; |
| 4 |
|
| 5 |
use WC_Shipping_Flat_Rate; |
| 6 |
|
| 7 |
class PickupPointDelivery extends WC_Shipping_Flat_Rate |
| 8 |
{ |
| 9 |
use ShippingMethodTrait { |
| 10 |
ShippingMethodTrait::instance_form_fields as trait_instance_form_fields; |
| 11 |
} |
| 12 |
|
| 13 |
public const ID = 'sendy_pickup_point'; |
| 14 |
|
| 15 |
public function __construct($instance_id = 0) |
| 16 |
{ |
| 17 |
$this->id = self::ID; |
| 18 |
$this->instance_id = absint($instance_id); |
| 19 |
$this->method_title = __('Sendy - Pickup Point Delivery', 'sendy'); |
| 20 |
$this->method_description = __('Let your customers choose a pick-up point', 'sendy'); |
| 21 |
|
| 22 |
$this->supports = [ |
| 23 |
'shipping-zones', |
| 24 |
'instance-settings', |
| 25 |
'instance-settings-modal', |
| 26 |
]; |
| 27 |
|
| 28 |
$this->init(); |
| 29 |
$this->init_form_fields(); |
| 30 |
$this->init_settings(); |
| 31 |
|
| 32 |
add_filter('woocommerce_shipping_instance_form_fields_' . $this->id, [$this, 'instance_form_fields'], 10, 1); |
| 33 |
add_action('woocommerce_update_options_shipping_' . $this->id, [$this, 'process_admin_options']); |
| 34 |
} |
| 35 |
|
| 36 |
/** |
| 37 |
* @param array<string,array<string,mixed>> $form_fields |
| 38 |
* @return array<string,array<string,mixed>> |
| 39 |
*/ |
| 40 |
public function instance_form_fields(array $form_fields): array |
| 41 |
{ |
| 42 |
$form_fields = $this->trait_instance_form_fields($form_fields); |
| 43 |
|
| 44 |
$form_fields['carrier'] = [ |
| 45 |
'title' => __('Carrier', 'sendy'), |
| 46 |
'type' => 'select', |
| 47 |
'options' => [ |
| 48 |
'DHL' => 'DHL eCommerce', |
| 49 |
'PostNL' => 'PostNL', |
| 50 |
'DPD' => 'DPD', |
| 51 |
], |
| 52 |
'class' => 'wc-enhanced-select', |
| 53 |
'default' => 'class', |
| 54 |
'description' => __('Select which carrier to show the pickup points for', 'sendy'), |
| 55 |
]; |
| 56 |
|
| 57 |
return $form_fields; |
| 58 |
} |
| 59 |
} |
| 60 |
|