add to cart links for products in home
This commit is contained in:
@@ -182,6 +182,25 @@ function materiotheme_preprocess_page(&$vars){
|
||||
// kint($vars['attributes']);
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
* Implements hook_form_alter
|
||||
*/
|
||||
function materiotheme_form_alter(&$form, FormStateInterface $form_state, $form_id) {
|
||||
// commerce_order_item_variation_cart_form_form_commerce_product_variation_3
|
||||
preg_match('/commerce_order_item_variation_cart_form_form_commerce_product_variation_(\d+)/', $form_id, $matches);
|
||||
if ($matches && isset($matches[1]) && $variation_id = $matches[1]) {
|
||||
// if (isset($form['#entity_type']) && $form['#entity_type'] == "commerce_order_item") {
|
||||
// $product = $form_state->storage['product'];
|
||||
// $storage = &$form_state->getStorage();
|
||||
// $product = $storage['product'];
|
||||
// $variations = $product->fields['variations'];
|
||||
$form['actions']['submit']['#attributes'] += array(
|
||||
"@click.prevent.stop" => "checkaddtocart(\$event, $variation_id)"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_form_alter
|
||||
*/
|
||||
|
Reference in New Issue
Block a user