Mise en forme add to cart et tpl

Tags:

Source https://drupalcommerce.org/discussions/13388/rendering-add-cart-buttons-...

on a ctools plugin content type
how to translate my node variables into a $content variable that had a view mode like it does in the node_preprocess functions :

<?php
function template_preprocess_NAME_OF_MY_TEMPLATE(&$vars) {
 
//Gather the available vars for the node
 
$node = &$vars['node'];
 
//Assign content a view_mode so we can render the add to cart button
 
$content = (node_view($node, 'full', NULL));
 
$vars['cart'] = $content['field_product'];  //Name of product reference field
}
?>
I have used the FULL view mode that correlates to the option in the 'Manage Display' tab on my Content Type that displays my products. As long as the product reference field on that view mode is set to use the 'Add to Cart form' format, the field can be rendered in the custom tpl like this:
<?php
 
print render($cart);
?>
...
logo drush