css
1 year ago
js
1 year ago
class-css.php
1 year ago
class-date.php
1 year ago
class-delivery-type.php
1 year ago
class-display-field.php
1 year ago
class-js.php
1 year ago
class-main.php
1 year ago
class-myaccount.php
1 year ago
class-order.php
1 year ago
class-pickup-location.php
1 year ago
class-shipping-method.php
1 year ago
class-time-range.php
1 year ago
class-time-slot.php
1 year ago
class-time.php
1 year ago
class-validate.php
1 year ago
class-woo-app.php
1 year ago
class-shipping-method.php
46 lines
| 1 | <?php |
| 2 | class pisol_dtt_shipping_method{ |
| 3 | |
| 4 | function __construct(){ |
| 5 | |
| 6 | add_filter( 'woocommerce_product_needs_shipping',array(__CLASS__, 'productNeedsShipping'), PHP_INT_MAX); |
| 7 | add_filter( 'woocommerce_cart_needs_shipping_address', array(__CLASS__, 'productNeedsShipping'), PHP_INT_MAX); |
| 8 | add_filter( 'woocommerce_customer_taxable_address', array($this, 'shopBasedTaxableAddress')); |
| 9 | } |
| 10 | |
| 11 | /** |
| 12 | * When pickup is selected we do the Tax calculation based on the shop |
| 13 | * base address |
| 14 | */ |
| 15 | function shopBasedTaxableAddress($location){ |
| 16 | if(self::disabled()) return $location; |
| 17 | |
| 18 | $type = pi_dtt_delivery_type::getType(); |
| 19 | |
| 20 | if($type != 'pickup') return $location; |
| 21 | |
| 22 | $country = WC()->countries->get_base_country(); |
| 23 | $state = WC()->countries->get_base_state(); |
| 24 | $postcode = WC()->countries->get_base_postcode(); |
| 25 | $city = WC()->countries->get_base_city(); |
| 26 | return array( $country, $state, $postcode, $city ); |
| 27 | } |
| 28 | |
| 29 | static function productNeedsShipping($val){ |
| 30 | |
| 31 | if(self::disabled()) return $val; |
| 32 | |
| 33 | $type = pi_dtt_delivery_type::getType(); |
| 34 | if($type == 'pickup'){ |
| 35 | return false; |
| 36 | } |
| 37 | |
| 38 | return $val; |
| 39 | } |
| 40 | |
| 41 | static function disabled(){ |
| 42 | return apply_filters('pisol_disable_dtt_completely',false); |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | new pisol_dtt_shipping_method(); |