\Barn2\Plugin\WC_Product_TableCart_Handler

This class handles caching for the product tables.

Summary

Methods
Properties
Constants
is_required()
register()
process_multi_cart()
add_to_cart_multi()
add_to_cart()
product_addons_cart_item_data_wrapper()
product_addons_validate_cart_item()
get_multi_cart_data()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
product_addons_add_cart_item_data()
fix_cart_data_product_ids()
No private properties found
N/A

Methods

is_required()

is_required()

register()

register()

process_multi_cart()

process_multi_cart()

add_to_cart_multi()

add_to_cart_multi(\Barn2\Plugin\WC_Product_Table\type  $products): array

Add multiple products to the cart in a single step.

Parameters

\Barn2\Plugin\WC_Product_Table\type $products
  • An array of products (including quantities and variation data) to add to the cart

Returns

array —

An array of product IDs => quantity added

add_to_cart()

add_to_cart(  $product_id,  $quantity = 1,  $variation_id = false,  $variations = false)

Parameters

$product_id
$quantity
$variation_id
$variations

product_addons_cart_item_data_wrapper()

product_addons_cart_item_data_wrapper(  $cart_item_data,  $product_id)

Parameters

$cart_item_data
$product_id

product_addons_validate_cart_item()

product_addons_validate_cart_item(  $passed,  $product_id,  $qty)

Parameters

$passed
$product_id
$qty

get_multi_cart_data()

get_multi_cart_data(): array

Get the posted multi cart data as an array, with the correct integer product IDs.

Returns

array —

The multi cart data (product IDs => product data)

product_addons_add_cart_item_data()

product_addons_add_cart_item_data(  $cart_item_data,  $product_id,  $post_data)

Parameters

$cart_item_data
$product_id
$post_data

fix_cart_data_product_ids()

fix_cart_data_product_ids(array  $cart_data): array

Posted cart_data uses indexes of the form 'p1234' where '1234' is the product ID.

This is because of a limitation of the JS serializeObject function. We run this function to remove the 'p' prefix from each index in the array.

Parameters

array $cart_data

The cart data to be sanitized

Returns

array —

The same array with keys replaced with the corresponding product ID