Problem
Add an arbitrary list of Shop-Script products with links, images, names, and prices to an email message.
Solution
Use this code as a template. Fill in desired values for variables listed at the beginning.
{if $wa->shop}
{$products = $wa->shop->productSet("bestsellers")} {* method to obtain a product list *}
{$domain = 'mydomain.com'} {* your domain name *}
{$route = '*'} {* your storefront address from Site app's "Structure" section *}
{$image_size = '200'} {* product image size *}
{$currency = 'USD'} {* currency to display product prices *}
{foreach $products as $product}
{$route_params = [
'product_url' => $product['url'],
'domain' => $domain,
'route' => $route
]}
{if (isset($product['category_url']))}
{$route_params['category_url'] = $product['category_url']}
{else}
{$route_params['category_url'] = ''}
{/if}
<p>
{strip}
<a href="{$wa->getUrl('shop/frontend/product', $route_params, true)}">
{if !empty($product.image_id)}
<img src="{$wa->shop->imgUrl([ 'id' => $product['image_id'], 'product_id' => $product['id'], 'filename' => $product['image_filename'], 'ext' => $product['ext'] ], $image_size, true)}"><br>
{/if}
{$product.name}
</a><br>
{shop_currency_html($product.price, $currency)}
{/strip}
</p>
{/foreach}
{/if}










0 comments
No comments yet.