Eeco_Gift_Cards_Checkout
in package
Table of Contents
- $gift_card : mixed
- the gift card currently processing
- __construct() : mixed
- bind actions
- add_order_item_meta() : mixed
- add meta for order items
- add_to_cart() : mixed
- fetches the add to cart template
- apply_gift_card() : array<string|int, mixed>
- apply gift card discount if it exists
- apply_gift_card_calculation() : array<string|int, mixed>
- re add gift card when calculating totals
- cart_item_price() : string
- set the correct price on mini cart
- create_gift_card() : string
- create new gift card and save it to database
- filter_cart_item_data() : array<string|int, mixed>
- add price to cart item
- filter_coupon_message() : string
- filter coupon success message to fit the gift card theme
- format_meta_data() : array<string|int, mixed>
- Format meta data of order line items
- generate_gift_card_id() : int|string
- generate gift card id
- is_gift_card_valid() : bool
- checks whether given gift card is valid or not
- new_order() : mixed
- checks the order for gift cards and generates them
- set_custom_cart_data() : array<string|int, mixed>
- set custom data to cart item meta
- set_price() : mixed
- set gift card price before calculating totals
- woocommerce_checkout_create_order() : mixed
- link used gift cards to the order
- get_gift_card() : Eeco_Gift_Card
- load the gift card from current instance or attempt to fetch from database
Properties
$gift_card
the gift card currently processing
private
mixed
$gift_card
=
ull
Methods
__construct()
bind actions
public
__construct() : mixed
Return values
mixed —add_order_item_meta()
add meta for order items
public
add_order_item_meta(WC_Order_Item $item, string $cart_item_key, array<string|int, mixed> $values, WC_Order $order) : mixed
Parameters
- $item : WC_Order_Item
-
order item
- $cart_item_key : string
-
The cart item data
- $values : array<string|int, mixed>
-
The data
- $order : WC_Order
-
The order
Return values
mixed —add_to_cart()
fetches the add to cart template
public
add_to_cart() : mixed
Return values
mixed —apply_gift_card()
apply gift card discount if it exists
public
apply_gift_card(array<string|int, mixed> $coupon_data, string $coupon_code[, bool|null $calc_taxes = true ]) : array<string|int, mixed>
Parameters
- $coupon_data : array<string|int, mixed>
-
Coupon data
- $coupon_code : string
-
Code of the coupon
- $calc_taxes : bool|null = true
-
Whether to calculate taxes
Return values
array<string|int, mixed> —Coupon data
apply_gift_card_calculation()
re add gift card when calculating totals
public
apply_gift_card_calculation(WC_Coupon $coupon, string $coupon_code) : array<string|int, mixed>
Parameters
- $coupon : WC_Coupon
-
The coupon
- $coupon_code : string
-
The code
Return values
array<string|int, mixed> —The coupon
cart_item_price()
set the correct price on mini cart
public
cart_item_price(string $html, array<string|int, mixed> $cart_item) : string
Parameters
- $html : string
-
Current price html
- $cart_item : array<string|int, mixed>
-
The cart item
Return values
string —Price html
create_gift_card()
create new gift card and save it to database
public
create_gift_card(WC_Order_Item_Product $item, WC_Order $order, string $expiration) : string
Parameters
- $item : WC_Order_Item_Product
-
the order item
- $order : WC_Order
-
Order object
- $expiration : string
-
When card will expire
Return values
string —The post id
filter_cart_item_data()
add price to cart item
public
filter_cart_item_data(array<string|int, mixed> $cart_item, int $product_id) : array<string|int, mixed>
Parameters
- $cart_item : array<string|int, mixed>
-
Cart item data
- $product_id : int
-
The product id to add
Return values
array<string|int, mixed> —Cart item data
filter_coupon_message()
filter coupon success message to fit the gift card theme
public
filter_coupon_message(string $msg, mixed $msg_code, WC_Coupon $coupon) : string
Parameters
- $msg : string
-
The message
- $msg_code : mixed
- $coupon : WC_Coupon
-
Coupon object
Return values
string —The message
format_meta_data()
Format meta data of order line items
public
format_meta_data(array<string|int, mixed> $formatted_data) : array<string|int, mixed>
Parameters
- $formatted_data : array<string|int, mixed>
-
Array of order meta data
Return values
array<string|int, mixed> —Meta data array
generate_gift_card_id()
generate gift card id
public
generate_gift_card_id(WC_Product $product) : int|string
Parameters
- $product : WC_Product
-
The product
Return values
int|string —The id
is_gift_card_valid()
checks whether given gift card is valid or not
public
is_gift_card_valid(bool $valid, WC_Coupon $coupon, array<string|int, mixed> $discounts) : bool
Parameters
- $valid : bool
-
Valid or not
- $coupon : WC_Coupon
-
The coupon data
- $discounts : array<string|int, mixed>
-
Current discounts
Return values
bool —Whether valid
new_order()
checks the order for gift cards and generates them
public
new_order(int $order_id[, mixed $order = null ]) : mixed
Parameters
- $order_id : int
-
The order id
- $order : mixed = null
Return values
mixed —set_custom_cart_data()
set custom data to cart item meta
public
set_custom_cart_data(array<string|int, mixed> $data, array<string|int, mixed> $item) : array<string|int, mixed>
Parameters
- $data : array<string|int, mixed>
-
The item data
- $item : array<string|int, mixed>
-
Cart item
Return values
array<string|int, mixed> —Cart item data
set_price()
set gift card price before calculating totals
public
set_price(WC_Cart $cart) : mixed
Parameters
- $cart : WC_Cart
-
The cart object
Return values
mixed —woocommerce_checkout_create_order()
link used gift cards to the order
public
woocommerce_checkout_create_order(int $order_id) : mixed
Parameters
- $order_id : int
-
The order id
Return values
mixed —get_gift_card()
load the gift card from current instance or attempt to fetch from database
private
get_gift_card(string $code) : Eeco_Gift_Card
Parameters
- $code : string
-
Gift card code