Forum
Variants help
Hi
I could do with a pointer with variants please. I have them setup in the product with this on the product page;
<?php perch_shop_product(perch_get('product'),[
'template' => 'products/product_details.html',
'variants' => true,
'filter' => 'slug',
'match' => 'eq',
'value' => perch_get('product') ]);
?>
and I have this on my product_details.html (along with my other template bits);
<perch:if exists="has_variants">
<perch:input id="product" type="select" class="variants" options="<perch:shop id="_variant_opts" type="hidden" />" placeholder="Please choose" required="true" />
<perch:else />
Diagnostics
Summary information
Perch Runway: 3.0.4, PHP: 5.4.45, MySQL: 5.5.46, with MySQLi
Server OS: Linux, cgi-fcgi
Installed apps: content (3.0.4), assets (3.0.4), categories (3.0.4), perch_shop_orders (1.2), perch_shop_products (1.2), perch_shop (1.2), perch_members (1.6.1)
App runtimes: <?php $apps_list = array( 'perch_members', 'perch_shop', );
PERCH_LOGINPATH: /perch
PERCH_PATH: /home/fullfatwebsite/public_html/stotto/perch
PERCH_CORE: /home/fullfatwebsite/public_html/stotto/perch/core
PERCH_RESFILEPATH: /home/fullfatwebsite/public_html/stotto/perch/resources
Image manipulation: GD
PHP limits: Max upload 25M, Max POST 128M, Memory: 256M, Total max file upload: 25M
F1: 0c66c2e1f82f9e0b7617b2cb8270f2c7
Resource folder writeable: Yes
DOCUMENT_ROOT: /home/fullfatwebsite/public_html/stotto
HTTP_HOST: stotto.fullfatwebsitedesign.co.uk
REQUEST_URI: /perch/core/settings/diagnostics/
SCRIPT_NAME: /perch/core/settings/diagnostics/index.php
and finally, debug on product page, which shows my variants/options, but on the page its just displaying "Standard Unlimited"
Debug Message - Perch Runway 3.0.4
SELECT p.pagePath, pr.routePattern, pr.routeRegExp, p.pageTemplate, pr.routeOrder, s.settingValue AS siteOffline FROM perch2_pages p LEFT JOIN perch2_page_routes pr ON p.pageID=pr.pageID LEFT JOIN perch2_settings s ON s.settingID='siteOffline' UNION SELECT NULL AS pagePath, pr2.routePattern, pr2.routeRegExp, pr2.templatePath AS pageTemplate, pr2.routeOrder, NULL AS siteOffline FROM perch2_page_routes pr2 WHERE templateID!=0 ORDER BY routeOrder ASC, pagePath ASC
Matched route: shop/product/[slug:product]
Using master page: /templates/pages/product.php
Page arguments:
Array
(
[0] => /shop/product/ballast-stothg0004
[product] => ballast-stothg0004
[1] => ballast-stothg0004
)
SELECT * FROM perch2_pages WHERE pagePath='/shop/product' LIMIT 1
SELECT * FROM perch2_shop_cart WHERE cartID=213
SELECT * FROM perch2_shop_cart WHERE cartID=213
SELECT * FROM perch2_shop_sales WHERE saleFrom<='2017-05-25 09:57:00' AND saleTo>'2017-05-25 09:57:00' AND saleActive=1 AND saleDeleted IS NULL ORDER BY saleOrder ASC
Using template: /templates/pages/attributes/seo.html
SELECT tbl.* FROM ( SELECT idx.itemID, main.*, idx2.indexValue as sortval FROM perch2_shop_index idx JOIN perch2_shop_products main ON idx.itemID=main.productID AND idx.itemKey='productID' JOIN perch2_shop_index idx2 ON idx.itemID=idx2.itemID AND idx.itemKey='productID' AND idx2.indexKey='_id' WHERE 1=1 AND ((idx.indexKey='slug' AND idx.indexValue='ballast-stothg0004')) AND idx.itemID=idx2.itemID AND idx.itemKey=idx2.itemKey GROUP BY idx.itemID, idx2.indexValue, productID ) as tbl WHERE (productDeleted IS NULL AND productStatus=1 AND parentID IS NULL) GROUP BY itemID, sortval ORDER BY sortval ASC
SELECT * FROM perch2_shop_products WHERE parentID IN ('54') AND productDeleted IS NULL
SELECT DISTINCT settingID, settingValue FROM perch2_settings WHERE userID=0
[1] Using template: /templates/shop/products/product_details.html
SELECT productID, productVariantDesc, stock_level FROM perch2_shop_products WHERE parentID=54 AND productDeleted IS NULL ORDER BY productOrder ASC
SELECT o.* FROM perch2_shop_options o, perch2_shop_product_options po WHERE o.optionID=po.optionID AND po.productID=54 AND o.optionDeleted IS NULL ORDER BY optionPrecendence ASC
SELECT valueID AS id, valueTitle AS title, valueSKUCode AS skucode FROM perch2_shop_option_values WHERE optionID=7 AND valueDeleted IS NULL ORDER BY valueOrder ASC
SELECT pov.prodoptID, pov.optionID, pov.valueID, o.optionTitle, ov.* FROM perch2_shop_product_option_values pov, perch2_shop_options o, perch2_shop_option_values ov WHERE pov.productID='54' AND pov.optionID=o.optionID AND pov.valueID=ov.valueID AND o.optionDeleted IS NULL AND ov.valueDeleted IS NULL AND o.optionID='7' ORDER BY o.optionPrecendence ASC, ov.valueOrder ASC
SELECT * FROM perch2_shop_currencies WHERE currencyID=47 LIMIT 1
SELECT * FROM perch2_shop_tax_groups WHERE groupID='1' AND groupDeleted IS NULL LIMIT 1
Missing variant.
Missing variant.
Missing variant.
Missing variant.
SELECT regionKey, regionHTML FROM perch2_content_regions WHERE regionPage='/shop/product' OR regionPage='*' ORDER BY regionPage DESC
SELECT pageID FROM perch2_pages WHERE pagePath='/shop/product' LIMIT 1
INSERT INTO perch2_content_regions(regionKey,regionPage,regionHTML,regionOptions,pageID) SELECT 'footer' AS regionKey,'/shop/product' AS regionPage,'<!-- Undefined content: footer -->' AS regionHTML,'' AS regionOptions,'37' AS pageID FROM (SELECT 1) AS dtable WHERE ( SELECT COUNT(*) FROM perch2_content_regions WHERE regionKey='footer' AND (regionPage='/shop/product' OR regionPage='*') )=0 LIMIT 1
UPDATE perch2_content_regions SET regionOrder=0 WHERE regionPage='/shop/product' AND regionKey='footer' LIMIT 1
Debug Message - Perch Runway 3.0.4
SELECT p.pagePath, pr.routePattern, pr.routeRegExp, p.pageTemplate, pr.routeOrder, s.settingValue AS siteOffline FROM perch2_pages p LEFT JOIN perch2_page_routes pr ON p.pageID=pr.pageID LEFT JOIN perch2_settings s ON s.settingID='siteOffline' UNION SELECT NULL AS pagePath, pr2.routePattern, pr2.routeRegExp, pr2.templatePath AS pageTemplate, pr2.routeOrder, NULL AS siteOffline FROM perch2_page_routes pr2 WHERE templateID!=0 ORDER BY routeOrder ASC, pagePath ASC
Matched route: shop/product/[slug:product]
Using master page: /templates/pages/product.php
Page arguments:
Array
(
[0] => /shop/product/ballast-stothg0004
[product] => ballast-stothg0004
[1] => ballast-stothg0004
)
SELECT * FROM perch2_pages WHERE pagePath='/shop/product' LIMIT 1
SELECT * FROM perch2_shop_cart WHERE cartID=213
SELECT * FROM perch2_shop_cart WHERE cartID=213
SELECT * FROM perch2_shop_sales WHERE saleFrom<='2017-05-25 09:57:00' AND saleTo>'2017-05-25 09:57:00' AND saleActive=1 AND saleDeleted IS NULL ORDER BY saleOrder ASC
Using template: /templates/pages/attributes/seo.html
SELECT tbl.* FROM ( SELECT idx.itemID, main.*, idx2.indexValue as sortval FROM perch2_shop_index idx JOIN perch2_shop_products main ON idx.itemID=main.productID AND idx.itemKey='productID' JOIN perch2_shop_index idx2 ON idx.itemID=idx2.itemID AND idx.itemKey='productID' AND idx2.indexKey='_id' WHERE 1=1 AND ((idx.indexKey='slug' AND idx.indexValue='ballast-stothg0004')) AND idx.itemID=idx2.itemID AND idx.itemKey=idx2.itemKey GROUP BY idx.itemID, idx2.indexValue, productID ) as tbl WHERE (productDeleted IS NULL AND productStatus=1 AND parentID IS NULL) GROUP BY itemID, sortval ORDER BY sortval ASC
SELECT * FROM perch2_shop_products WHERE parentID IN ('54') AND productDeleted IS NULL
SELECT DISTINCT settingID, settingValue FROM perch2_settings WHERE userID=0
[1] Using template: /templates/shop/products/product_details.html
SELECT productID, productVariantDesc, stock_level FROM perch2_shop_products WHERE parentID=54 AND productDeleted IS NULL ORDER BY productOrder ASC
SELECT o.* FROM perch2_shop_options o, perch2_shop_product_options po WHERE o.optionID=po.optionID AND po.productID=54 AND o.optionDeleted IS NULL ORDER BY optionPrecendence ASC
SELECT valueID AS id, valueTitle AS title, valueSKUCode AS skucode FROM perch2_shop_option_values WHERE optionID=7 AND valueDeleted IS NULL ORDER BY valueOrder ASC
SELECT pov.prodoptID, pov.optionID, pov.valueID, o.optionTitle, ov.* FROM perch2_shop_product_option_values pov, perch2_shop_options o, perch2_shop_option_values ov WHERE pov.productID='54' AND pov.optionID=o.optionID AND pov.valueID=ov.valueID AND o.optionDeleted IS NULL AND ov.valueDeleted IS NULL AND o.optionID='7' ORDER BY o.optionPrecendence ASC, ov.valueOrder ASC
SELECT * FROM perch2_shop_currencies WHERE currencyID=47 LIMIT 1
SELECT * FROM perch2_shop_tax_groups WHERE groupID='1' AND groupDeleted IS NULL LIMIT 1
Missing variant.
Missing variant.
Missing variant.
Missing variant.
SELECT regionKey, regionHTML FROM perch2_content_regions WHERE regionPage='/shop/product' OR regionPage='*' ORDER BY regionPage DESC
SELECT pageID FROM perch2_pages WHERE pagePath='/shop/product' LIMIT 1
INSERT INTO perch2_content_regions(regionKey,regionPage,regionHTML,regionOptions,pageID) SELECT 'footer' AS regionKey,'/shop/product' AS regionPage,'<!-- Undefined content: footer -->' AS regionHTML,'' AS regionOptions,'37' AS pageID FROM (SELECT 1) AS dtable WHERE ( SELECT COUNT(*) FROM perch2_content_regions WHERE regionKey='footer' AND (regionPage='/shop/product' OR regionPage='*') )=0 LIMIT 1
UPDATE perch2_content_regions SET regionOrder=0 WHERE regionPage='/shop/product' AND regionKey='footer' LIMIT 1
Request time: 0.0759
Process time: 0.0754
Memory: 6.3443
I've tried a few things, including;
But not having any joy, am I close? I've run out of things to try...
Wayne
You need to put variants inside the variants tag.
https://docs.grabaperch.com/templates/apps/shop/products/
I don't know what you're trying to do with the code above so can't be more specific I'm afraid.
Hi Jonathan
Sorry, I didn't get a notification. I've added the variants to my product_details.html;
Which displays the variants as a string. How do I select the template for variants (eg, like variants_list.html)?
Thanks Wayne
They're just a part of your product template, much like repeaters or categories would be so your html will wrap around the variant tags in your code above.
<perch:showall/> in your template will list out all the variables that are available to your template.
Thanks Jonathan
I'm still not getting it. Do you know of any examples out there I could look at... I've looked at nest examples where I got some of the existing code from.
Regards Wayne
Have you got a design you are converting into Shop or are you doing it as you go? The variants will conform to however you design them. They are not a fixed list of items apart from any special shop tags you might use.
Generate some options (size, colour etc) and then assign them to the product. Then generate variants based upon the options used by the product. You can then edit each variant as you see fit.
Your variant template is called variant.html – this is the form that's generated in the product's variant tab on the control panel. Any template tags in there will output in the product page if you put it between the perch:variant tags and they are assigned to the product. If they are not then nothing will show.
Here's a product template I wrote a variant for recently - ignore the markup:
Thanks Jonathan
That's a massive help and I now have the variants listed, just need the price to display, but I'm sure its my issue/typo.
Thanks again.
Wayne