add to cart links for products in home

This commit is contained in:
2021-06-09 13:06:52 +02:00
parent d9d2180f94
commit 352223500f
25 changed files with 561 additions and 249 deletions

View File

@@ -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
*/