| 1 |
<?php |
| 2 |
|
| 3 |
class WooMailerLiteSession { |
| 4 |
|
| 5 |
public static function get() |
| 6 |
{ |
| 7 |
return WC()->session; |
| 8 |
} |
| 9 |
|
| 10 |
public static function set($key, $value) |
| 11 |
{ |
| 12 |
WC()->session->set($key, $value); |
| 13 |
} |
| 14 |
|
| 15 |
public static function cart() |
| 16 |
{ |
| 17 |
return json_encode(WC()->cart->get_cart()); |
| 18 |
} |
| 19 |
|
| 20 |
public static function customer() |
| 21 |
{ |
| 22 |
return WC()->get_customer(); |
| 23 |
} |
| 24 |
|
| 25 |
public static function billingEmail() |
| 26 |
{ |
| 27 |
$customer = WC()->cart->get_customer(); |
| 28 |
return $customer->get_billing_email() ?: $customer->get_email(); |
| 29 |
} |
| 30 |
|
| 31 |
public static function getMLCustomer() |
| 32 |
{ |
| 33 |
return WC()->session->get('woo_mailerlite_customer_data'); |
| 34 |
} |
| 35 |
|
| 36 |
public static function getMLCartHash() |
| 37 |
{ |
| 38 |
if (WC()->session) { |
| 39 |
return WC()->session->get('woo_mailerlite_cart_hash'); |
| 40 |
} |
| 41 |
return null; |
| 42 |
} |
| 43 |
|
| 44 |
public static function getMlCheckbox() |
| 45 |
{ |
| 46 |
return WC()->session->get('woo_mailerlite_checkbox') ?? false; |
| 47 |
} |
| 48 |
|
| 49 |
public static function getMLCartStageCacheKey() |
| 50 |
{ |
| 51 |
return sprintf('woo_ml_cart_stage:%s', self::getMLCartHash()); |
| 52 |
} |
| 53 |
} |
| 54 |
|