PluginProbe ʕ •ᴥ•ʔ
PiWeb Delivery & Pickup Date Time for WooCommerce / 3.0.49.3
PiWeb Delivery & Pickup Date Time for WooCommerce v3.0.49.3
3.0.63 3.0.62 3.0.61 3.0.60 3.0.49.49 3.0.49.6 3.0.49.60 3.0.49.61 3.0.49.62 3.0.49.63 3.0.49.64 3.0.49.66 3.0.49.67 3.0.49.69 3.0.49.7 3.0.49.70 3.0.49.72 3.0.49.73 3.0.49.74 3.0.49.76 3.0.49.77 3.0.49.79 3.0.49.9 3.0.49.90 3.0.49.91 3.0.49.92 3.0.49.93 3.0.49.94 3.0.49.96 3.0.49.97 3.0.49.99 trunk 1.0 1.1 1.2 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 2.9.17 3.0.47 3.0.49 3.0.49.1 3.0.49.10 3.0.49.11 3.0.49.12 3.0.49.13 3.0.49.16 3.0.49.17 3.0.49.19 3.0.49.2 3.0.49.20 3.0.49.21 3.0.49.22 3.0.49.23 3.0.49.24 3.0.49.26 3.0.49.27 3.0.49.29 3.0.49.3 3.0.49.30 3.0.49.31 3.0.49.32 3.0.49.33 3.0.49.34 3.0.49.36 3.0.49.37 3.0.49.39 3.0.49.4 3.0.49.40 3.0.49.41 3.0.49.42 3.0.49.43 3.0.49.44 3.0.49.46 3.0.49.47
pi-woocommerce-order-date-time-and-type / public / class-delivery-type.php
pi-woocommerce-order-date-time-and-type / public Last commit date
css 2 years ago js 2 years ago class-css.php 2 years ago class-date.php 2 years ago class-delivery-type.php 2 years ago class-display-field.php 2 years ago class-js.php 2 years ago class-main.php 2 years ago class-order.php 2 years ago class-pickup-location.php 2 years ago class-shipping-method.php 2 years ago class-time-range.php 2 years ago class-time-slot.php 2 years ago class-time.php 2 years ago class-validate.php 2 years ago class-woo-app.php 2 years ago
class-delivery-type.php
108 lines
1 <?php
2 if ( ! defined( 'WPINC' ) ) {
3 die;
4 }
5 class pi_dtt_delivery_type{
6
7 public $default_type;
8
9 function __construct(){
10 $this->default_type = pisol_dtt_get_setting('pi_default_type', 'delivery');
11 }
12
13 static function getType(){
14 $obj = new self();
15 $type = $obj->getDeliveryType();
16 return $type;
17 }
18
19 function availableDeliveryType(){
20 $aloud_types = pisol_dtt_get_setting('pi_type', "Both");
21 if($aloud_types == "Both"){
22 return 'both';
23 }
24
25 if($aloud_types == "Pickup"){
26 return 'pickup';
27 }
28
29 if($aloud_types == "Delivery"){
30 return 'delivery';
31 }
32 }
33
34 function getDeliveryType(){
35 $available_type = $this->availableDeliveryType();
36
37 if($this->checkDeliveryTypeSetInSession( $available_type )){
38 $type = WC()->session->get( 'pi_delivery_type', false);
39 return $type;
40 }
41
42 if($available_type != "both"){
43 $this->setDeliveryType($available_type);
44 return $available_type;
45 }
46
47 return $this->setDeliveryType($this->default_type);
48 }
49
50 function setDeliveryType($type){
51 if($this->checkSession()){
52 WC()->session->set("pi_delivery_type", $type);
53 return WC()->session->get( 'pi_delivery_type', false);
54 }
55 return false;
56 }
57
58 function checkDeliveryTypeSetInSession($available_type){
59 if($this->checkSession()){
60 $type = WC()->session->get( 'pi_delivery_type', false);
61 if($available_type == 'both' && ($type == 'pickup' || $type == 'delivery')){
62 return true;
63 }
64
65 if($available_type == 'pickup' && ($type == 'pickup')){
66 return true;
67 }
68
69 if($available_type == 'delivery' && ($type == 'delivery')){
70 return true;
71 }
72
73
74 if($this->allowedCustomType($type)){
75 return true;
76 }
77 }
78 return false;
79 }
80
81 function allowedCustomType($type){
82 $custom_type = apply_filters('pisol_dtt_custom_delivery_type',"");
83 if($custom_type == "") return false;
84
85 if(is_array($custom_type)){
86 if(in_array($type, $custom_type)){
87 return true;
88 }else{
89 return false;
90 }
91 }else{
92 if($type == $custom_type){
93 return true;
94 }else{
95 return false;
96 }
97 }
98
99 }
100
101 function checkSession(){
102 if(function_exists('WC') && isset(WC()->session)){
103 return true;
104 }
105 return false;
106 }
107
108 }