PluginProbe
Gift Up Gift Cards for WordPress and WooCommerce / trunk
Gift Up Gift Cards for WordPress and WooCommerce vtrunk
3.2.2 3.1.7 3.1.8 3.2 3.2.1 wp5.2 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 1.2 1.2.1 1.2.2 1.2.3 1.2.4 All 131 releases
gift-up / includes / class-giftup-cache.php

class-giftup-cache.php in Gift Up Gift Cards for WordPress and WooCommerce trunk, at includes/class-giftup-cache.php

46 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class GiftUp_Cache
4 {
5 // Cache API gift card get API result per web request
6 public $giftcard = null;
7
8 // Cache some cart totals
9 public $applied_gift_card_balance = 0;
10
11 public function gift_card_found() {
12 return $this->giftcard != null
13 && strlen($this->get_accepted_gift_card_code()) > 0;
14 }
15
16 public function get_requested_gift_card_code() {
17 if (WC()->session) {
18 return WC()->session->get( GIFTUP_REQUESTED_GIFTCARD_CODE );
19 }
20 return null;
21 }
22
23 public function get_accepted_gift_card_code() {
24 if (WC()->session) {
25 return WC()->session->get( GIFTUP_ACCEPTED_GIFTCARD_CODE );
26 }
27 return null;
28 }
29
30 public function set_gift_card_code( $code ) {
31 if (WC()->session) {
32 WC()->session->set( GIFTUP_REQUESTED_GIFTCARD_CODE, $code );
33
34 if (empty($code) || $code == null) {
35 WC()->session->set( GIFTUP_ACCEPTED_GIFTCARD_CODE, null );
36 }
37 else if (GiftUp()->api->get_gift_card($code) != null) {
38 WC()->session->set( GIFTUP_ACCEPTED_GIFTCARD_CODE, $this->giftcard['code'] );
39 }
40 else {
41 WC()->session->set( GIFTUP_ACCEPTED_GIFTCARD_CODE, null );
42 }
43 }
44 }
45 }
46