Hello,

I'm trying to theme the dc-ajax-add-cart-popup.html.twig file and I would like to access to some product fields.

I see on the template description that we can access {{ product_variation }}, {{ product_variation_entity }} but I don't know how to get access to the parent {{ commerce_product }} entity.

Could you please point me the right direction ?

Thanks

Alex

Comments

Alexandre360 created an issue. See original summary.

subhojit777’s picture

Status: Active » Closed (works as designed)

In your custom preprocess you have to do product_variation_entity->getProduct() (see https://github.com/drupalcommerce/commerce/blob/8.x-2.x/modules/product/...).

More information regarding Twig debugging - https://www.drupal.org/docs/8/theming/twig/debugging-twig-templates

Alexandre360’s picture

Thank you for the answer

What would be the name of the preprocess HOOK for ajax cart popup ? I still have some difficulties with drupal 8 naming convention.

function hook_preprocess_HOOK(&$variables) {

}

For the first "hook", I think I have to put my theme name if I put that function in mytheme.theme in my theme root folder, but I don't know what name to give to the second "HOOK"

Thank you

Alex