WC_Shipping_Local_Pickup

Local Pickup Shipping Method.

Defined (1)

The class is defined in the following location(s).

/includes/shipping/local-pickup/class-wc-shipping-local-pickup.php  
  1. class WC_Shipping_Local_Pickup extends WC_Shipping_Method { 
  2.  
  3. /** 
  4. * Constructor. 
  5. */ 
  6. public function __construct( $instance_id = 0 ) { 
  7. $this->id = 'local_pickup'; 
  8. $this->instance_id = absint( $instance_id ); 
  9. $this->method_title = __( 'Local pickup', 'woocommerce' ); 
  10. $this->method_description = __( 'Allow customers to pick up orders themselves. By default, when using local pickup store base taxes will apply regardless of customer address.', 'woocommerce' ); 
  11. $this->supports = array( 
  12. 'shipping-zones',  
  13. 'instance-settings',  
  14. 'instance-settings-modal',  
  15. ); 
  16. $this->init(); 
  17.  
  18. /** 
  19. * Initialize local pickup. 
  20. */ 
  21. public function init() { 
  22.  
  23. // Load the settings. 
  24. $this->init_form_fields(); 
  25. $this->init_settings(); 
  26.  
  27. // Define user set variables 
  28. $this->title = $this->get_option( 'title' ); 
  29. $this->tax_status = $this->get_option( 'tax_status' ); 
  30. $this->cost = $this->get_option( 'cost' ); 
  31.  
  32. // Actions 
  33. add_action( 'woocommerce_update_options_shipping_' . $this->id, array( $this, 'process_admin_options' ) ); 
  34.  
  35. /** 
  36. * calculate_shipping function. 
  37. * Calculate local pickup shipping. 
  38. */ 
  39. public function calculate_shipping( $package = array() ) { 
  40. $this->add_rate( array( 
  41. 'label' => $this->title,  
  42. 'package' => $package,  
  43. 'cost' => $this->cost,  
  44. ) ); 
  45.  
  46. /** 
  47. * Init form fields. 
  48. */ 
  49. public function init_form_fields() { 
  50. $this->instance_form_fields = array( 
  51. 'title' => array( 
  52. 'title' => __( 'Title', 'woocommerce' ),  
  53. 'type' => 'text',  
  54. 'description' => __( 'This controls the title which the user sees during checkout.', 'woocommerce' ),  
  55. 'default' => __( 'Local pickup', 'woocommerce' ),  
  56. 'desc_tip' => true,  
  57. ),  
  58. 'tax_status' => array( 
  59. 'title' => __( 'Tax status', 'woocommerce' ),  
  60. 'type' => 'select',  
  61. 'class' => 'wc-enhanced-select',  
  62. 'default' => 'taxable',  
  63. 'options' => array( 
  64. 'taxable' => __( 'Taxable', 'woocommerce' ),  
  65. 'none' => _x( 'None', 'Tax status', 'woocommerce' ),  
  66. ),  
  67. ),  
  68. 'cost' => array( 
  69. 'title' => __( 'Cost', 'woocommerce' ),  
  70. 'type' => 'text',  
  71. 'placeholder' => '0',  
  72. 'description' => __( 'Optional cost for local pickup.', 'woocommerce' ),  
  73. 'default' => '',  
  74. 'desc_tip' => true,  
  75. ),  
  76. );