You are here

function hook_uc_add_to_cart_data in Ubercart 8.4

Same name and namespace in other branches
  1. 7.3 uc_cart/uc_cart.api.php \hook_uc_add_to_cart_data()

Adds extra information to a cart item's "data" array.

This is effectively the submit handler of any alterations to the Add to Cart form. It provides a standard way to store the extra information so that it can be used by hook_uc_add_to_cart().

Parameters

$form_values: The values submitted to the Add to Cart form.

Return value

array An array of data to be merged into the item added to the cart.

2 functions implement hook_uc_add_to_cart_data()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

uc_attribute_uc_add_to_cart_data in uc_attribute/uc_attribute.module
Implements hook_uc_add_to_cart_data().
uc_product_uc_add_to_cart_data in uc_product/uc_product.module
Implements hook_uc_add_to_cart_data().
8 invocations of hook_uc_add_to_cart_data()
AddToCartForm::validateForm in uc_product/src/Form/AddToCartForm.php
Form validation handler.
BuyItNowForm::submitForm in uc_product/src/Form/BuyItNowForm.php
Form submission handler.
CartLinksForm::submitForm in uc_cart_links/src/Form/CartLinksForm.php
Form submission handler.
Products::addProductForm in uc_order/src/Plugin/Ubercart/OrderPane/Products.php
Sets the quantity and attributes of a product added to the order.
Products::addProductSubmit in uc_order/src/Plugin/Ubercart/OrderPane/Products.php
Form submit callback: add a product to an order.

... See full list

File

uc_cart/uc_cart.api.php, line 75
Hooks provided by the Cart module.

Code

function hook_uc_add_to_cart_data($form_values) {
  $node = Node::load($form_values['nid']);
  return [
    'module' => 'uc_product',
    'shippable' => $node->shippable->value,
  ];
}