I've been struggling to use the shopify Buy button for the past 2 days, My webshop has products with 3 or 4 different variants with different pricing options for larger quantities (so variants look a bit like:
1 box, price per box $50
5 boxes, price per box $30
10 boxes, price per box $20
In my shopify store I removed the quantity selection and when they select 10 boxes, I automatically add 10x that variant in the customer's cart, this way it displays nicely in the catalog (box X starting at $20).
Now I would like to add a buy button channel on another website, and created the embed code to show a collection of the different products.
The problem is, it will always show the first variants price (which is the highest price $50 in the above example)
Is there a way to render the collection to display the cheapest variant price?
What I have so far:
<div id='collection-component-5e11b1274c8'></div>
<script type="text/javascript">
/*<![CDATA[*/
(function () {
var scriptURL = 'https://sdks.shopifycdn.com/buy-button/latest/buy-button-storefront.min.js';
if (window.ShopifyBuy) {
if (window.ShopifyBuy.UI) {
ShopifyBuyInit();
} else {
loadScript();
}
} else {
loadScript();
}
function loadScript() {
var script = document.createElement('script');
script.async = true;
script.src = scriptURL;
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(script);
script.onload = ShopifyBuyInit;
}
function ShopifyBuyInit() {
var client = ShopifyBuy.buildClient({
domain: 'mydomain',
apiKey: 'mykey',
appId: '6',
});
ShopifyBuy.UI.onReady(client).then(function (ui) {
ui.createComponent('collection', {
id: 157236225,
node: document.getElementById('collection-component-5e11b1274c8'),
moneyFormat: '%E2%82%AC%7B%7Bamount%7D%7D',
events :{
afterRender : function(e){
console.log('after Render');
}},
options: {
"product": {
"variantId": "all",
"isButton": false,
"contents": {
"imgWithCarousel": false,
"variantTitle": false,
"description": false,
"buttonWithQuantity": false,
"quantity": false
},
templates : {
price: "{{ data.selectedVariant.price }}"
},
DOMEvents: {
'change .shopify-buy__option-select': function (event, target) {
var data = target;
var product = ui.components;
console.log(product);
console.log(product.product);
console.log(product.productSet);
console.log(product.model);
console.log(Object.getOwnPropertyNames(product));
product.updateQuantity(() => parseInt(6, 10));
}
},
"styles": {
"product": {
"text-align": "left",
"#media (min-width: 601px)": {
"max-width": "calc(33.33333% - 30px)",
"margin-left": "30px",
"margin-bottom": "50px"
}
},
"button": {
"font-family": "Open Sans, sans-serif",
"font-weight": "normal"
},
"variantTitle": {
"font-family": "Open Sans, sans-serif",
"font-weight": "normal"
},
"title": {
"font-family": "Open Sans, sans-serif",
"font-weight": "normal",
"font-size": "16px"
},
"description": {
"font-family": "Open Sans, sans-serif",
"font-weight": "normal"
},
"price": {
"font-family": "Open Sans, sans-serif",
"font-size": "16px",
"font-weight": "normal"
},
"compareAt": {
"font-family": "Open Sans, sans-serif",
"font-weight": "normal",
"font-size": "13.6px"
}
},
"googleFonts": [
"Open Sans",
"Open Sans",
"Open Sans",
"Open Sans",
"Open Sans",
"Open Sans"
]
},
"cart": {
"contents": {
"button": true
},
"text": {
"title": "Winkelmand",
"total": "subtotaal",
"notice": "",
"button": "Afrekenen"
},
"styles": {
"button": {
"font-family": "Open Sans, sans-serif",
"font-weight": "normal"
},
"footer": {
"background-color": "#ffffff"
}
},
"googleFonts": [
"Open Sans"
]
},
"modalProduct": {
"contents": {
"img": false,
"imgWithCarousel": true,
"variantTitle": false,
"buttonWithQuantity": true,
"button": false,
"quantity": false
},
"text": {
"button": "In winkelmand"
},
"styles": {
"product": {
"#media (min-width: 601px)": {
"max-width": "100%",
"margin-left": "0px",
"margin-bottom": "0px"
}
},
"button": {
"font-family": "Open Sans, sans-serif",
"font-weight": "normal"
},
"variantTitle": {
"font-family": "Open Sans, sans-serif",
"font-weight": "normal"
},
"title": {
"font-family": "Open Sans, sans-serif",
"font-weight": "normal",
"font-size": "30px"
},
"description": {
"font-family": "Open Sans, sans-serif",
"font-weight": "normal"
},
"price": {
"font-family": "Open Sans, sans-serif",
"font-weight": "normal"
},
"compareAt": {
"font-family": "Open Sans, sans-serif",
"font-weight": "normal"
}
},
"googleFonts": [
"Open Sans",
"Open Sans",
"Open Sans",
"Open Sans",
"Open Sans",
"Open Sans"
]
},
"toggle": {
"styles": {
"toggle": {
"font-family": "Open Sans, sans-serif",
"font-weight": "normal"
}
},
"googleFonts": [
"Open Sans"
]
},
"option": {
"styles": {
"label": {
"font-family": "Open Sans, sans-serif"
},
"select": {
"font-family": "Open Sans, sans-serif"
}
},
"googleFonts": [
"Open Sans",
"Open Sans"
]
},
"productSet": {
"styles": {
"products": {
"#media (min-width: 601px)": {
"margin-left": "-30px"
}
}
}
}
}
});
});
}
})();
/*]]>*/
</script>
In the DomEvents you see I try to update the quantity to 6, whenever a users selects a different option from a product in the collection. This seems to work, but I only change the quantity for the first product, if you happen to know how I can update the quantity of the changed product feel free to jump in and let me know..
The easiest way is to reorder the variants in the shopify backend.
To update the quantity when an option is selected you can use the userEvent "updateVariant" in the product object
Which is called whenever another option is selected.
In my case the first 2 chars of the variant are the amount of the product.
events: { "updateVariant" : function(e){
console.log('update variant');
console.log(e.model.selectedVariant.title.substr(0,2).trim());
e.updateQuantity(() => parseInt(e.model.selectedVariant.title.substr(0,2).trim()));
}
Related
It's very strange. I installed the VuePWA-Plugin and configured it in the package.json like this:
"pwa": {
"name": "Poolio",
"themeColor": "#205c94",
"msTileColor": "#205c94",
"display": "fullscreen",
"appleMobileWebAppCapable": "yes",
"appleMobileWebAppStatusBarStyle": "#205c94",
"pwa.iconPaths": {
"favicon32": "./img/icons/favicon-32x32.png",
"favicon16": "./img/icons/favicon-16x16.png",
"favicon96": "./img/icons/favicon-96x96.png",
"appleTouchIcon": "./img/icons/apple-icon-152x152.png",
"msTitleImage": "./img/icons/ms-icon-144x144.png"
}
},
But it doesn't use any of my settings in the manifest.json (beside of the name, but this must be used by another setting, cause it doesn't change, if I change it)
I asked myself where it takes the themeColor and so I searched in the hole app folder for the hexcode #4DBA87, which is written in the manifest. But didn't find anything...
Heres the manifest output:
{
"name": "Poolio",
"short_name": "Poolio",
"theme_color": "#4DBA87",
"icons": [
{ "src": "./img/icons/android-chrome-192x192.png", "sizes": "192x192", "type": "image/png" },
{ "src": "./img/icons/android-chrome-512x512.png", "sizes": "512x512", "type": "image/png" },
{ "src": "./img/icons/android-chrome-maskable-192x192.png", "sizes": "192x192", "type": "image/png", "purpose": "maskable" },
{ "src": "./img/icons/android-chrome-maskable-512x512.png", "sizes": "512x512", "type": "image/png", "purpose": "maskable" }
],
"start_url": ".",
"display": "standalone",
"background_color": "#000000"
}
You can put all your manifest options inside pwa.manifestOptions. It would be something like this inside your vue.config.js:
module.exports = {
pwa: {
manifestOptions: {
name: "App Name",
short_name: "Short Name",
start_url: "./",
display: "standalone",
theme_color: "#000000",
icons: [
{
src: "./favicon.svg",
sizes: "512x512",
type: "image/svg+xml",
purpose: "any maskable",
},
],
},
themeColor: "#4DBA87",
msTileColor: "#000000",
appleMobileWebAppCapable: "yes",
appleMobileWebAppStatusBarStyle: "black",
iconPaths: {
maskicon: null,
favicon32: "./favicon32.png",
favicon16: "./favicon16.png",
appleTouchIcon: null,
msTileImage: null,
},
// configure the workbox plugin
workboxPluginMode: "GenerateSW",
},
};
Check out LinusBorg answers to this issue.
#vue/cli-plugin-pwa plugin internally uses webpack's workbox plugin. The color #4DBA87 you are getting is the default color set by the plugin.
You can read more about this plugin configuration here, https://www.npmjs.com/package/#vue/cli-plugin-pwa
To configure it to your liking via package.json you have to put your configurations inside the vue property. eg:
"vue": {
"pwa": {
"name": "Poolio",
"themeColor": "#205c94",
"msTileColor": "#205c94",
"appleMobileWebAppCapable": "yes",
"appleMobileWebAppStatusBarStyle": "#205c94",
"iconPaths": {
"favicon32": "./img/icons/favicon-32x32.png",
"favicon16": "./img/icons/favicon-16x16.png",
"favicon96": "./img/icons/favicon-96x96.png",
"appleTouchIcon": "./img/icons/apple-icon-152x152.png",
"msTitleImage": "./img/icons/ms-icon-144x144.png"
},
"workboxPluginMode": "InjectManifest",
"workboxOptions": {
"swSrc": "src/service-worker.js",
},
}
}
I am creating a graph with Cytoscape.js on my website, to show admins the connections among users. Everything is fine, but some graph are not drawn down. No errors in console, but the canvas seems empty.
For example, a graph that is not drawn has 20 EDGES and 18 NODES.
If I remove some edges, the graph is drawn and showed. No matter to which node or edge I remove: if I reach 18 EDGES it shows. So I thought "maybe it's too large".
But actually I have bigger graphs (37 edges) that are drawn without problems.
What can be the problem?
This is a graph that it's not showing. By the way, is there an online website where I can test this structure? Thanks
{
"elements": {
"nodes": [
{"data": {"id": "1"}},
{"data": {"id": "2"}},
{"data": {"id": "3"}},
{"data": {"id": "4"}},
{"data": {"id": "5"}},
{"data": {"id": "6"}},
{"data": {"id": "7"}},
{"data": {"id": "8"}},
{"data": {"id": "9"}},
{"data": {"id": "10"}},
{"data": {"id": "11"}},
{"data": {"id": "12"}},
{"data": {"id": "13"}},
{"data": {"id": "14"}},
{"data": {"id": "18"}},
{"data": {"id": "15"}},
{"data": {"id": "16"}},
{"data": {"id": "17"}}
],
"edges": [{
"data": {
"source": "1",
"target": "2"
}
}, {
"data": {
"source": "1",
"target": "3"
}
}, {
"data": {
"source": "4",
"target": "3"
}
}, {
"data": {
"source": "5",
"target": "3"
}
}, {
"data": {
"source": "1",
"target": "6"
}
}, {
"data": {
"source": "7",
"target": "6"
}
}, {
"data": {
"source": "1",
"target": "8"
}
}, {
"data": {
"source": "9",
"target": "1"
}
}, {
"data": {
"source": "1",
"target": "9"
}
}, {
"data": {
"source": "1",
"target": "10"
}
}, {
"data": {
"source": "4",
"target": "10"
}
}, {
"data": {
"source": "1",
"target": "11"
}
}, {
"data": {
"source": "1",
"target": "4"
}
}, {
"data": {
"source": "8",
"target": "12"
}
}, {
"data": {
"source": "14",
"target": "13"
}
}, {
"data": {
"source": "8",
"target": "13"
}
}, {
"data": {
"source": "15",
"target": "18"
}
}, {
"data": {
"source": "11",
"target": "18"
}
}, {
"data": {
"source": "11",
"target": "16"
}
}, {
"data": {
"source": "17",
"target": "16"
}
}],
},
}
I got the elements to display just fine:
var cy = window.cy = cytoscape({
container: document.getElementById('cy'),
boxSelectionEnabled: false,
autounselectify: true,
style: [{
selector: 'node',
css: {
'content': 'data(id)',
'text-valign': 'center',
'text-halign': 'center',
'height': '60px',
'width': '60px',
'border-color': 'black',
'border-opacity': '1',
'border-width': '10px'
}
},
{
selector: '$node > node',
css: {
'padding-top': '10px',
'padding-left': '10px',
'padding-bottom': '10px',
'padding-right': '10px',
'text-valign': 'top',
'text-halign': 'center',
'background-color': '#bbb'
}
},
{
selector: 'edge',
css: {
'target-arrow-shape': 'triangle'
}
},
{
selector: ':selected',
css: {
'background-color': 'black',
'line-color': 'black',
'target-arrow-color': 'black',
'source-arrow-color': 'black'
}
}
],
elements: {
nodes: [{
data: {
id: "1"
}
},
{
data: {
id: "2"
}
},
{
data: {
id: "3"
}
},
{
data: {
id: "4"
}
},
{
data: {
id: "5"
}
},
{
data: {
id: "6"
}
},
{
data: {
id: "7"
}
},
{
data: {
id: "8"
}
},
{
data: {
id: "9"
}
},
{
data: {
id: "10"
}
},
{
data: {
id: "11"
}
},
{
data: {
id: "12"
}
},
{
data: {
id: "13"
}
},
{
data: {
id: "14"
}
},
{
data: {
id: "15"
}
},
{
data: {
id: "16"
}
},
{
data: {
id: "17"
}
},
{
data: {
id: "18"
}
}
],
edges: [{
data: {
source: "1",
target: "2"
}
},
{
data: {
source: "1",
target: "3"
}
},
{
data: {
source: "4",
target: "3"
}
},
{
data: {
source: "5",
target: "3"
}
},
{
data: {
source: "1",
target: "6"
}
},
{
data: {
source: "7",
target: "6"
}
},
{
data: {
source: "1",
target: "8"
}
},
{
data: {
source: "9",
target: "1"
}
},
{
data: {
source: "1",
target: "9"
}
},
{
data: {
source: "1",
target: "10"
}
},
{
data: {
source: "4",
target: "10"
}
},
{
data: {
source: "1",
target: "11"
}
},
{
data: {
source: "1",
target: "4"
}
},
{
data: {
source: "8",
target: "12"
}
},
{
data: {
source: "14",
target: "13"
}
},
{
data: {
source: "8",
target: "13"
}
},
{
data: {
source: "15",
target: "18"
}
},
{
data: {
source: "11",
target: "18"
}
},
{
data: {
source: "11",
target: "16"
}
},
{
data: {
source: "17",
target: "16"
}
}
]
},
layout: {
name: 'breadthfirst',
directed: true,
padding: 15
}
});
body {
font: 14px helvetica neue, helvetica, arial, sans-serif;
}
#cy {
height: 100%;
width: 100%;
position: absolute;
left: 0;
top: 0;
float: left;
}
<html>
<head>
<meta charset=utf-8 />
<meta name="viewport" content="user-scalable=no, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, minimal-ui">
<script src="https://cdnjs.cloudflare.com/ajax/libs/cytoscape/3.2.17/cytoscape.min.js"></script>
</head>
<body>
<div id="cy"></div>
</body>
</html>
I am trying to make some of checkboxes checked and disabled in jqxTreeGrid in below code:
$("#treegrid_portfolio").jqxTreeGrid(
{
source: dataAdapter,
pageable: true,
pagerMode: 'advanced',
pageSizeMode: 'root',
pageSize: 5,
pageSizeOptions: ['1', '2', '3', '5', '10'],
columnsResize: true,
sortable: true,
filterable: true,
theme: "custom",
filterMode: 'advanced',
altRows: false,
checkboxes: true,
columnsReorder: true,
hierarchicalCheckboxes: true,
width: getWidth("TreeGrid"),
/*width: "100%",*/
ready: function () {
$("#treegrid_portfolio").jqxTreeGrid('expandRow', '1');
$("#treegrid_portfolio").jqxTreeGrid('expandRow', '2');
}
,
columns: [
{
text: "ID", dataField: "formattedID", width: 120, pinned: true, cellclassname: "requestIdCls", resizable: false
}
,
{
text: '', datafield: 'alert', cellsrenderer: linkrendererAlert, width: 60, pinned: true, cellclassname: "alert_column", cellsAlign: 'center', filterable: false, resizable: false
}
,
{
text: "Portfolio Items Name", dataField: "PortfolioItem_Name", width: 200
}
,
{
text: "Agile Central Project Name", dataField: "AC_ProjectName", width: 200
}
]
}
);
Is it possible to make the same on grid ready function. I have done some research on the jqwidget. But didn't got any solution or clues. Please help me any one.
You need to make below changes also just put id attribute for each of your column data .Then put the id for selecting checkbox to set true.
follow this link i have get a fiddle for you Invoke the uncheckRow method.
var data = [{
"id": "1",
"name": "Corporate Headquarters",
"budget": "1230000",
"location": "Las Vegas",
"children": [{
"id": "2",
"name": "Finance Division",
"budget": "423000",
"location": "San Antonio",
"children": [{
"id": "3",
"name": "Accounting Department",
"budget": "113000",
"location": "San Antonio"
}, {
"id": "4",
"name": "Investment Department",
"budget": "310000",
"location": "San Antonio",
children: [{
"id": "5",
"name": "Banking Office",
"budget": "240000",
"location": "San Antonio"
}, {
"id": "6",
"name": "Bonds Office",
"budget": "70000",
"location": "San Antonio"
}, ]
}]
}, {
"id": "7",
"name": "Operations Division",
"budget": "600000",
"location": "Miami",
"children": [{
"id": "8",
"name": "Manufacturing Department",
"budget": "300000",
"location": "Miami"
}, {
"id": "9",
"name": "Public Relations Department",
"budget": "200000",
"location": "Miami"
}, {
"id": "10",
"name": "Sales Department",
"budget": "100000",
"location": "Miami"
}]
}, {
"id": "11",
"name": "Research Division",
"budget": "200000",
"location": "Boston"
}]
}];
var source = {
dataType: "json",
dataFields: [{
name: "name",
type: "string"
}, {
name: "budget",
type: "number"
}, {
name: "id",
type: "number"
}, {
name: "children",
type: "array"
}, {
name: "location",
type: "string"
}],
hierarchy: {
root: "children"
},
localData: data,
id: "id"
};
var dataAdapter = new $.jqx.dataAdapter(source, {
loadComplete: function () {
}
});
// create jqxTreeGrid.
$("#treeGrid").jqxTreeGrid({
source: dataAdapter,
altRows: true,
width: 680,
theme:'energyblue',
checkboxes: true,
ready: function () {
$("#treeGrid").jqxTreeGrid('expandRow', '1');
$("#treeGrid").jqxTreeGrid('expandRow', '2');
},
columns: [{
text: "Name",
align: "center",
dataField: "name",
width: 300
}, {
text: "Budget",
cellsAlign: "center",
align: "center",
dataField: "budget",
cellsFormat: "c2",
width: 250
}, {
text: "Location",
dataField: "location",
cellsAlign: "center",
align: "center"
}]
});
$("#jqxbutton").jqxButton({
theme: 'energyblue',
height: 30
});
$("#treeGrid").jqxTreeGrid('checkRow',2);
The last line of code
$("#treeGrid").jqxTreeGrid('checkRow',2); is reason to check the checkbox true while loading.
Please makesure if any help required.Hope it may help.
To check rows on grid ready function use checkRow method, and lockRow will disable editing of the row and give the row gray style.
3 or 8 are Unique ID which identifies the row Id (data field in data source).
ready: function () {
$("#treeGrid").jqxTreeGrid('checkRow', '3');
$("#treeGrid").jqxTreeGrid('lockRow', '3');
$("#treeGrid").jqxTreeGrid('checkRow', '8');
$("#treeGrid").jqxTreeGrid('lockRow', '8');
},
To disable checkboxes you can use rowUncheck event to prevent uncheck by checking the row again.
$('#treeGrid').on('rowUncheck', function (event) {
$("#treeGrid").jqxTreeGrid('checkRow', '3');
$("#treeGrid").jqxTreeGrid('checkRow', '8');
});
$("#treeGrid").jqxTreeGrid({
// ......
});
I have implemented 'Shpoify Buy Button' in Symfony Project. I want restrict add more quantity to cart.
Below is my json code of 'Shpoify Buy Button':
Shopify.render('shopify-btn', {{ current_program.shopifyId|json_encode|raw }}, {
"product": {
"buttonDestination": "checkout",
"variantId": "all",
"contents": {
"img": false,
"imgWithCarousel": false,
"title": false,
"variantTitle": false,
"price": false,
"description": false,
"buttonWithQuantity": false,
"quantity": false
},
"text": {
"button": "BUY NOW"
},
"styles": {
"product": {
"#media (min-width: 601px)": {
"max-width": "100%",
"margin-left": "0",
"margin-bottom": "50px"
}
},
"button": {
"background-color": "#3771c8",
"font-size": "18px",
"font-weight": "bold",
"height": "61px",
":hover": {
"background-color": "#3266b4"
},
":focus": {
"background-color": "#3266b4"
}
},
"title": {
"font-size": "26px"
},
"price": {
"font-size": "18px"
},
"compareAt": {
"font-size": "15px"
}
}
},
"cart": {
"contents": {
"button": false,
"quantity": false
},
"text": {
"total": "Total"
},
"popup":false,
"styles": {
"button": {
"background-color": "#3771c8",
":hover": {
"background-color": "#3266b4"
},
":focus": {
"background-color": "#3266b4"
}
},
"footer": {
"background-color": "#ffffff"
}
}
},
"modalProduct": {
"contents": {
"img": false,
"imgWithCarousel": true,
"variantTitle": false,
"buttonWithQuantity": false,
"quantity": false
},
"styles": {
"product": {
"#media (min-width: 601px)": {
"max-width": "100%",
"margin-left": "0px",
"margin-bottom": "0px"
}
},
"button": {
"background-color": "#3771c8",
"font-size": "15px",
":hover": {
"background-color": "#3266b4"
},
":focus": {
"background-color": "#3266b4"
}
}
}
},
"toggle": {
"styles": {
"toggle": {
"background-color": "#3771c8",
":hover": {
"background-color": "#3266b4"
},
":focus": {
"background-color": "#3266b4"
}
}
}
},
"productSet": {
"styles": {
"products": {
"#media (min-width: 601px)": {
"margin-left": "-20px"
}
}
}
}
});
By using above json I can add / edit product quantity in cart.
I need to add only one quantity in cart also don't want add quantity by every click of "Shopify Buy Button" so how I can do that? Can anyone help me please?
I've been looking for this answer for some time and cannot find anything on it. Does anyone know if metafields or metadata can be included in the Shopify Buy Button products?
Some background - We have a Shopify site that has the Shopify App "Product Reviews" installed and used heavily on the site. There is a secondary site (WordPress) where we are using the Shopify Buy Button code to add some products specific to that site (several collections from the Shopify store). We want to add the Product Reviews to the modal pop-up for the products we have set up on the buy buttons. The data for the reviews is stored in product.metafields.spr.reviews.
We have added custom templates and classes to the buy button embed code to custom style the look, but for the life of me, I cannot find out if getting the metadata for the product is even possible. I am very familiar with WordPress, so I have created an automated way to add the products and collections to the pages we want them on, and the buy button code is added when the page has a product or collection to display. So, customizing the code is not an issue.
I could use the API to pull product metadata and then insert it onto the popup, but that just seems like a lot of extra work and I do not want to go down that path if there is a better solution.
Is there a way to do it using the ui.createComponent? And if so, how would you add that to the code?
Here is some of the code for a reference (it is output via php so there are a few php variables in it):
ui.createComponent( 'collection', {
id: <?php echo $idkey; ?>, // collection id
node: document.getElementById( 'collection-component-<?php echo $idval['hash'];?>' ), //collection unique hash
moneyFormat: '%24%7B%7Bamount%7D%7D',
options: {
"product": {
"iframe": false,
"buttonDestination": "modal",
"variantId": "all",
"contents": {
"imgWithCarousel": false,
"variantTitle": false,
"options": false,
"description": false,
"buttonWithQuantity": false,
"quantity": false
},
"events":{
"openModal": function (product) { /* debug only */ },
},
"text": {
"button": "VIEW PRODUCT INFO",
},
},
"cart": {
"contents": {"button": true},
"styles": {
"button": {
"background-color": "#761b79",
"font-family": "Droid Sans, sans-serif",
":hover": {"background-color": "#6a186d"},
":focus": {"background-color": "#6a186d"},
"font-weight": "normal"
},
"footer": {"background-color": "#ffffff"}
},
"googleFonts": ["Droid Sans"]
},
"modalProduct": {
"iframe": false,
"layout": "horizontal",
"contents": {
"img": false,
"imgWithCarousel": true,
"variantTitle": true,
"buttonWithQuantity": true,
"button": false,
"quantity": false,
"reviews": true
},
"DOMEvents": {
'click .product-reviews': function (evt, target) { /* debug code only */}
},
"templates": {
"title" : '<h1 class="{{data.classes.modalProduct.title}}" data-element="product.title">{{data.title}}</h1>',
"reviews": '<div class="{{data.classes.product.reviews}}">[ review data goes here ]</div>'
},
"classes": {
"reviews" : "product-reviews"
},
"order" :[
"imgWithCarousel",
"title",
"price",
"buttonWithQuantity",
"reviews",
"description"
],
"styles": {
"button": {
"background-color": "#761b79",
"font-family": "Droid Sans, sans-serif",
":hover": {"background-color": "#6a186d"},
":focus": {"background-color": "#6a186d"},
"font-weight": "normal"
},
"reviews" : {
"color" : "#444"
}
},
},
"toggle": {
"styles": {
"toggle": {
"font-family": "Droid Sans, sans-serif",
"background-color": "#761b79",
":hover": {"background-color": "#6a186d"},
":focus": {"background-color": "#6a186d"},
"font-weight": "normal"
}
},
"googleFonts": ["Droid Sans"]
},
"productSet": {"iframe": false,}
}
});
Sorry, metafields are not accessible through BuyButton.js or the JavaScript Buy SDK. For more information see this thread: https://github.com/Shopify/js-buy-sdk/issues/168