Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Snipcart to v3.0.25; fix Snipcart JS errors #26

Merged
merged 6 commits into from
Nov 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions exampleSite/config.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
######################## default configuration ####################
baseURL = "https://examplesite.com"
languageCode = "en-us"
languageCode = "en"
title = "Hargo | Hugo Ecommerce Site"
theme = "hargo"
summaryLength = "20"
Expand Down Expand Up @@ -101,7 +101,7 @@ location = "Dhaka, Bangladedsh"
copyright = "| Copyright © 2019 [Gethugothemes](https://gethugothemes.com) All Rights Reserved |"
# Snipcart Credentials
snipcartApiKey = "M2E5YjA3NjMtYzRiYS00YzVjLWEyYWYtNDY5ZDI0OWZhYjg5"
currencySimbol = "$"
currencySymbol = "$"

# Preloader
[params.preloader]
Expand Down
18 changes: 9 additions & 9 deletions layouts/_default/baseof.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<!DOCTYPE html>
<html lang="{{ with site.LanguageCode }}{{ . }}{{ else }}en-US{{ end }}">
{{- partial "head.html" . -}}
<body>
{{- partial "preloader.html" . -}}
{{- partial "header.html" . -}}
{{- block "main" . }}{{- end }}
{{- partial "footer.html" . -}}
</body>
</html>
<html lang="{{ with site.LanguageCode }}{{ . }}{{ else }}en{{ end }}">
{{- partial "head.html" . -}}
<body>
{{- partial "preloader.html" . -}}
{{- partial "header.html" . -}}
{{- block "main" . }}{{- end }}
{{- partial "footer.html" . -}}
</body>
</html>
4 changes: 2 additions & 2 deletions layouts/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ <h2>{{ .title | markdownify }}</h2>
<a href="{{ .Permalink }}" class="h4">{{ .Title }}</a>
<p>{{ .Params.Description }}</p>
<div class="mb-4">
<span class="lead text-primary">{{ .Params.Price }} {{ site.Params.currencySimbol }}</span>
<s>{{ .Params.PriceBefore }} {{ site.Params.currencySimbol }}</s>
<span class="lead text-primary">{{ .Params.Price }} {{ site.Params.currencySymbol }}</span>
<s>{{ .Params.PriceBefore }} {{ site.Params.currencySymbol }}</s>
</div>
<button class="snipcart-add-item btn btn-sm btn-outline-primary" data-item-id="{{ .Params.ProductID }}"
data-item-name="{{ .Title }}" {{ range first 1 .Params.Images }} data-item-image="{{ .image | absURL }}"
Expand Down
119 changes: 55 additions & 64 deletions layouts/partials/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ <h5 class="font-weight-medium mb-4">Connect With Us</h5>
<li class="mb-3"><i class="ti-location-pin text-primary mr-2"></i> {{ site.Params.location }}
</li>
</ul>
<!-- social icon -->
<!-- Social Icons -->
<ul class="list-inline">
{{ range site.Params.social }}
<li class="list-inline-item"><a href="{{ .link | safeURL }}"><i class="{{ .icon }} text-primary"></i></a></li>
Expand All @@ -49,84 +49,75 @@ <h5 class="font-weight-medium mb-4">Contact us</h5>
</div>
</footer>

{{ "<!-- Google Map API -->" | safeHTML }}
{{ with site.Params.snipcartApiKey }}
{{ "<!-- Snipcart -->" | safeHTML }}
<div id="snipcart" data-api-key="{{ . }}" hidden></div>
{{ end }}

{{ "<!-- Google Maps API -->" | safeHTML }}
<script src="{{ site.Params.gmapAPI | absURL }}"></script>
{{ "<!-- JS Plugins -->" | safeHTML }}
{{ range site.Params.plugins.js}}
<script src="{{ .link | absURL }}"></script>
{{ end }}

<!-- snipcart -->
{{ with site.Params.snipcartApiKey }}
<script type="text/javascript" id="snipcart" src="https://cdn.snipcart.com/themes/v3.0.21/default/snipcart.js"
data-api-key="{{ site.Params.snipcartApiKey }}"></script>
<script>
Snipcart.execute('registerLocale', 'en', {
powered_by: "Enlazaa"
});
</script>
{{ end }}

{{ "<!-- Main Script -->" | safeHTML }}
{{ $script := resources.Get "js/script.js" | minify}}
<script src="{{ $script.Permalink }}"></script>


{{ with site.Params.googleAnalitycsID }}
{{ "<!-- google analitycs -->" | safeHTML }}
{{ "<!-- Google Analytics -->" | safeHTML }}
<script>
(function (i, s, o, g, r, a, m) {
i['GoogleAnalyticsObject'] = r;
i[r] = i[r] || function () {
(i[r].q = i[r].q || []).push(arguments)
}, i[r].l = 1 * new Date();
a = s.createElement(o),
m = s.getElementsByTagName(o)[0];
a.async = 1;
a.src = g;
m.parentNode.insertBefore(a, m)
})(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');
ga('create', '{{ . }}', 'auto');
ga('send', 'pageview');
(function (i, s, o, g, r, a, m) {
i['GoogleAnalyticsObject'] = r;
i[r] = i[r] || function () {
(i[r].q = i[r].q || []).push(arguments)
}, i[r].l = 1 * new Date();
a = s.createElement(o),
m = s.getElementsByTagName(o)[0];
a.async = 1;
a.src = g;
m.parentNode.insertBefore(a, m)
})(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');
ga('create', '{{ . }}', 'auto');
ga('send', 'pageview');
</script>
{{ end }}

<!-- product rating -->
{{ if site.Params.rating.enable }}
<script type="text/javascript">
(function (d, t, e, m) {

// Async Rating-Widget initialization.
window.RW_Async_Init = function () {

RW.init({
huid: "{{ site.Params.rating.websiteID }}",
uid: "{{ site.Params.rating.publicKey }}",
source: "website",
options: {
"size": "medium",
"style": "oxygen",
"isDummy": false
}
});
RW.render();
};
// Append Rating-Widget JavaScript library.
var rw, s = d.getElementsByTagName(e)[0],
id = "rw-js",
l = d.location,
ck = "Y" + t.getFullYear() +
"M" + t.getMonth() + "D" + t.getDate(),
p = l.protocol,
f = ((l.search.indexOf("DBG=") > -1) ? "" : ".min"),
a = ("https:" == p ? "secure." + m + "js/" : "js." + m);
if (d.getElementById(id)) return;
rw = d.createElement(e);
rw.id = id;
rw.async = true;
rw.type = "text/javascript";
rw.src = p + "//" + a + "external" + f + ".js?ck=" + ck;
s.parentNode.insertBefore(rw, s);
}(document, new Date(), "script", "rating-widget.com/"));
{{ "<!-- Product Ratings -->" | safeHTML }}
<script>
(function (d, t, e, m) {
// Async Rating-Widget initialization
window.RW_Async_Init = function () {
RW.init({
huid: "{{ site.Params.rating.websiteID }}",
uid: "{{ site.Params.rating.publicKey }}",
source: "website",
options: {
"size": "medium",
"style": "oxygen",
"isDummy": false
}
});
RW.render();
};
// Append Rating-Widget JavaScript library
var rw, s = d.getElementsByTagName(e)[0],
id = "rw-js",
l = d.location,
ck = "Y" + t.getFullYear() +
"M" + t.getMonth() + "D" + t.getDate(),
p = l.protocol,
f = ((l.search.indexOf("DBG=") > -1) ? "" : ".min"),
a = ("https:" == p ? "secure." + m + "js/" : "js." + m);
if (d.getElementById(id)) return;
rw = d.createElement(e);
rw.id = id;
rw.async = true;
rw.type = "text/javascript";
rw.src = p + "//" + a + "external" + f + ".js?ck=" + ck;
s.parentNode.insertBefore(rw, s);
}(document, new Date(), "script", "rating-widget.com/"));
</script>
{{ end }}
23 changes: 13 additions & 10 deletions layouts/partials/head.html
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
<head>
<meta charset="utf-8">
<meta charset="UTF-8">
<title>{{ .Title }}</title>

{{ "<!-- mobile responsive meta -->" | safeHTML }}
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
{{ "<!-- Mobile Responsive Meta -->" | safeHTML }}
<meta name="viewport" content="width=device-width, initial-scale=1">
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<meta name="description" content="{{ with .Description }}{{ . }}{{ else }}{{ with site.Params.description }}{{ . }}{{ end }}{{ end }}">
{{ with site.Params.author }}<meta name="author" content="{{ . }}">{{ end }}
{{ hugo.Generator }}

{{ "<!-- plugins -->" | safeHTML }}
{{ "<!-- Plugins -->" | safeHTML }}
{{ range site.Params.plugins.css }}
<link rel="stylesheet" href="{{ .link | absURL }}">
{{ end }}
<link rel="preconnect" href="https://app.snipcart.com">
<link rel="preconnect" href="https://cdn.snipcart.com">
<link id="snipcart-theme" type="text/css" href="https://cdn.snipcart.com/themes/v3.0.21/default/snipcart.css" rel="stylesheet">
<script async src="https://cdn.snipcart.com/themes/v3.0.21/default/snipcart.js"></script>

{{ with site.Params.snipcartApiKey }}
{{ "<!-- Snipcart -->" | safeHTML }}
<link rel="preconnect" href="https://app.snipcart.com/">
<link rel="preconnect" href="https://cdn.snipcart.com/">
<link rel="stylesheet" href="https://cdn.snipcart.com/themes/v3.0.25/default/snipcart.css">
<script async src="https://cdn.snipcart.com/themes/v3.0.25/default/snipcart.js"></script>
{{ end }}

{{ "<!-- Main Stylesheet -->" | safeHTML }}
{{ $styles := resources.Get "scss/style.scss" | toCSS | minify }}
<link rel="stylesheet" href="{{ $styles.Permalink }}" media="screen">

{{ "<!--Favicon-->" | safeHTML }}
{{ "<!-- Favicon -->" | safeHTML }}
<link rel="shortcut icon" href="{{ `images/favicon.png` | absURL }} " type="image/x-icon">
<link rel="icon" href="{{ `images/favicon.png` | absURL }} " type="image/x-icon">

</head>
4 changes: 2 additions & 2 deletions layouts/products/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
<a href="{{ .Permalink }}" class="h4">{{ .Title }}</a>
<p>{{ .Params.Description }}</p>
<div class="mb-4">
<span class="lead text-primary">{{ .Params.Price }} {{ site.Params.currencySimbol }}</span>
<s>{{ .Params.PriceBefore }} {{ site.Params.currencySimbol }}</s>
<span class="lead text-primary">{{ .Params.Price }} {{ site.Params.currencySymbol }}</span>
<s>{{ .Params.PriceBefore }} {{ site.Params.currencySymbol }}</s>
</div>
<button class="snipcart-add-item btn btn-sm btn-outline-primary" data-item-id="{{ .Params.ProductID }}"
data-item-name="{{ .Title }}" {{ range first 1 .Params.Images }} data-item-image="{{ .image | absURL }}"
Expand Down
4 changes: 2 additions & 2 deletions layouts/products/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ <h4 class="font-weight-medium">{{ .Title }}</h4>
<div class="rw-ui-container"></div>
{{ end }}
<div class="my-4">
<span class="lead text-primary font-weight-medium">{{ .Params.Price }} {{ site.Params.currencySimbol }}</span>
<s>{{ .Params.PriceBefore }} {{ site.Params.currencySimbol }}</s>
<span class="lead text-primary font-weight-medium">{{ .Params.Price }} {{ site.Params.currencySymbol }}</span>
<s>{{ .Params.PriceBefore }} {{ site.Params.currencySymbol }}</s>
</div>
<h5>Short Description</h5>
<p>{{ .Params.ShortDescription | markdownify }}</p>
Expand Down