I am using Hotcakes e-commerce tools for my website. My website is using DNN platform.
Because I have 2 different websites and products need to track into Google e-commerce, therefore I need 2 set of Google e-commerce code.
One is ga('ecommerce:send'); which is fine, the other one has to be ga('Hatch.ecommerce:send');
However Hotcakes does not allow me to modify Google e-commerce code. So I have to turn it off and edit it myself into the view model
I have implemented the code but it causes view error on the page.
Can anyone help me with this issue?
It gave this error message “An error has occurred. Error: Checkout is currently unavailable.”
This is the code for “receipt.cshtml”. I have added near the bottom for Google e-commerce code:
#model Hotcakes.Modules.Core.Models.OrderViewModel
<div class="hc-receipt">
<h2>Thank you for purchasing</h2>
We know you will love creating beautiful embroidery designs with our Hatch products.<br /><br />
Click here to download Hatch Embroidery<br /><br />
<strong>You are not required to download Hatch If you purchased:</strong>
<ul>
<li>Additional Hatch add-ons</li>
<li>An UPGRADE to Embroidery Creator or Embroidery Digitizer</li>
<li>Hatch Fonts Packs</li>
</ul>
Simply RESTART the software for your new purchase to be available.<br />
Have fun and please share your creations with us on our Facebook page<br />
#Html.Partial("_SetFirstPassword")
#Html.Partial("_ViewOrder", Model)
#for (int i = 0; i < Model.Items.Count(); i++)
{
var item = Model.Items.ElementAt(i);
#item.ProductName
<span>#item.ProductSku</span><br />
**<script type="text/javascript">
ga('Hatch.ecommerce:addTransaction', {
'id': '149428',
'affiliation': 'Hatch Embroidery Online Shop',
'revenue': '0',
'shipping': '0',
'tax': '#model.LocalOrder.TotalTax',
'city': '#model.LocalOrder.BillingAddress.City',
'state': '#model.LocalOrder.BillingAddress.RegionDisplayName',
'country': '#model.LocalOrder.BillingAddress.CountryDisplayName'
});
ga('Hatch.ecommerce:addItem', {
'id': '#item.Id',
'name': '#item.ProductName',
'sku': '#item.ProductSku',
'category': 'Hatch Product',
'price': '#item.AdjustedPricePerItem',
'quantity': '#item.Quantity'
});
ga('Hatch.ecommerce:send');
</script>**
}
</div>
I figured it has to be inside the loop if customer buying multiple products….
It will be great if you can give some hint or help with this…..
Thanks
Jack
In looking at your code, there appeared to be some typo's in "Model" versus "model", additional spaces and characters in the script tag, and the product name wasn't being used correctly in the way that Razor expects to use it. I'm not sure if this will fix all of the issues you encountered, but they appeared to all be Razor syntax and typo issues so far.
#model Hotcakes.Modules.Core.Models.OrderViewModel
<div class="hc-receipt">
<h2>Thank you for purchasing</h2>
We know you will love creating beautiful embroidery designs with our Hatch products.<br /><br />
Click here to download Hatch Embroidery<br /><br />
<strong>You are not required to download Hatch If you purchased:</strong>
<ul>
<li>Additional Hatch add-ons</li>
<li>An UPGRADE to Embroidery Creator or Embroidery Digitizer</li>
<li>Hatch Fonts Packs</li>
</ul>
Simply RESTART the software for your new purchase to be available.<br />
Have fun and please share your creations with us on our Facebook page<br />
#Html.Partial("_SetFirstPassword")
#Html.Partial("_ViewOrder", Model)
#for (int i = 0; i < Model.Items.Count(); i++)
{
var item = #Model.Items.ElementAt(i);
<text>#item.ProductName</text>
<span>#item.ProductSku</span><br />
<script type="text/javascript">
ga('Hatch.ecommerce:addTransaction', {
'id': '149428',
'affiliation': 'Hatch Embroidery Online Shop',
'revenue': '0',
'shipping': '0',
'tax': '#Model.LocalOrder.TotalTax',
'city': '#Model.LocalOrder.BillingAddress.City',
'state': '#Model.LocalOrder.BillingAddress.RegionDisplayName',
'country': '#Model.LocalOrder.BillingAddress.CountryDisplayName'
});
ga('Hatch.ecommerce:addItem', {
'id': '#item.Id',
'name': '#item.ProductName',
'sku': '#item.ProductSku',
'category': 'Hatch Product',
'price': '#item.AdjustedPricePerItem',
'quantity': '#item.Quantity'
});
ga('Hatch.ecommerce:send');
</script>
}
</div>
Related
I am using the sample RTMP Injection application for testing purposes. I want to modify the app in such a way that the injected RTMP stream should be the first video to occur in the grid of remote streams. Can someone please help?
You could set the first item of your grid with a similar code from agora-broadcast-client.js in https://github.com/digitallysavvy/agora-web-broadcast-demo using Vanilla JS:
// RTMP Connection (UI Component)
function addExternalTransmitionMiniView(rtmpUrl){
var container = $('#rtmp-controlers');
// append the remote stream template to #remote-streams
container.append(
$('<div/>', {'id': 'rtmp-container', 'class': 'container row justify-content-end mb-2'}).append(
$('<div/>', {'class': 'pulse-container'}).append(
$('<button/>', {'id': 'rtmp-toggle', 'class': 'btn btn-lg col-flex pulse-button pulse-anim mt-2'})
),
$('<input/>', {'id': 'rtmp-url', 'val': rtmpUrl, 'class': 'form-control col-flex" value="rtmps://live.facebook.com', 'type': 'text', 'disabled': true}),
$('<button/>', {'id': 'removeRtmpUrl', 'class': 'btn btn-lg col-flex close-btn'}).append(
$('<i/>', {'class': 'fas fa-xs fa-trash'})
)
)
);
}
You can hence set where you want the stream to be injected.
Is there anyway to use JSON-LD without including the script inline in the HTML, but still get Google (& other) spiders to find it? Looking around I've seen some conflicting information.
If this was the JSON-LD file:
<script type="application/ld+json">
{
"#context" : "http://schema.org",
"#type" : "WebSite",
"name" : "Example Site",
"alternateName" : "example",
"description" : "Welcome to this WebSite",
"headline" : "Welcome to Website",
"logo" : "https://example.com/public/images/logo.png",
"url" : "https://example.com/"
}
</script>
And I have this in the head of the HTML:
<script src="/public/json-ld.json" type="application/ld+json"></script>
EDIT: I've also tried:
<link href="/public/json-ld.json" rel="alternate" type="application/ld+" />
Google Spiders seem to miss it and so does the testing tool unless I point it directly at the file. I'm trying to work around unsafe-inline in the CSP. And the only thing I can find is this, which would work in Chrome but don't want to be firing console errors on every other browser. Plus, I just like the idea of Schema.org data being abstracted out of the page structure. Would adding the JSON-LD to the sitemap for Google Webmaster Tools help?
Apologies, total noob to JSON-lD and keep ending up in email documentation (this would be for a site) or old documentation.
True, it can not be made external and it is not supported inline, but you can still achieve what you want by injecting it into the DOM via a JavaScript file.
Note: I am using an array for neatness so I can segment all the structured data elements and add an infinite amount of them. I have a more complicated version of this code on my websites and actually have an external server side rendered file masquerading as a JavaScript file.
An yes Google search bot does understand it. May take days for it to register and using Webmaster tools to force a re-crawl does not seem to force a refresh of JSON-LD data - seems like you just have to wait.
var structuredData = {
schema: {
corporation: {
'#context': 'http://schema.org',
'#type': 'Corporation',
'name': 'Acme',
'url': 'https://acme.com',
'contactPoint':
{
'#type': 'ContactPoint',
'telephone': '+1-1234-567-890',
'contactType': 'customer service',
'areaServed': 'US'
}
},
service: {
'#context': 'http://schema.org/',
'#type': 'Service',
'name': 'Code optimization',
'serviceOutput' : 'Externalized json',
'description': 'Inline json to externalized json'
},
},
init: function () {
var g = [];
var sd = structuredData;
g.push(sd.schema.corporation);
g.push(sd.schema.service);
//etc.
var o = document.createElement('script');
o.type = 'application/ld+json';
o.innerHTML = JSON.stringify(g);
var d = document; (d.head || d.body).appendChild(o);
}
}
structuredData.init();
I have this awesome working code that pulls Autocomplete suggestions from Wikipedia. This is really useful, except that I'd like it to only recommend Bands. So for instance, typing in "Pink" would only return /bands/ that start with the word "Pink", rather than everything in the world dealing with 'Pink'.
Does anyone know how to accomplish this? http://codepen.io/anon/pen/VePapK
I found there's a way to filter results by category by using the query action here (rather than opensearch), but the strange thing is that there doesn't seem to be a broad "Music" or "Bands" category. So that's opening even more unanswered questions.... Any help appreciated.
EDIT: Alternatively, if anyone knows an easier way to feature an updated list of all significant bands on your site's dropdown, please let me know.
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<form method="get" id="search">
<input type="text" class="searchbox" value="Type here.. " onblur="if(this.value == '') { this.value = 'Type here..'; }" onfocus="if(this.value == 'Type here..') { this.value = ''; }" name="s">
<button type="submit">Submit</button>
</form>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.3/themes/smoothness/jquery-ui.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.3/jquery-ui.min.js"></script>
<script type="text/javascript">
$(".searchbox").autocomplete({
source: function(request, response) {
console.log(request.term);
$.ajax({
url: "http://en.wikipedia.org/w/api.php",
dataType: "jsonp",
data: {
'action': "opensearch",
'format': "json",
'search': request.term
},
success: function(data) {
response(data[1]);
}
});
}
});
</script>
</body>
</html>
There are indeed a lot of questions to open about Wikipedia's category system. Thankfully, there is a better way.
Here is an alternative approach that will get you what you need from Wikipedia search: you can use search parameters with Wikipedia's CirrusSearch API to get articles within a category (via incategory:<category title>), with a link to another Wikipedia page (via linksto:<page name>), or by a page that transcludes a common Wikipedia template (via hastemplate:<template name>). If you know the right Wikipedia category or page, you can use the first two options easily. Although the last one might sound odd, Wikipedia's well organized template system may be your best bet. Many band articles will have a common infobox on the right that will help you narrow your search to bands.
You can use CirrusSearch and hastemplate:Infobox_musical_artist together like this:
https://en.wikipedia.org/w/api.php?action=query&list=search&format=json&srsearch=hastemplate%3AInfobox_musical_artist+daft
Which returns a list of pages in this format:
{
"batchcomplete": "",
"continue": {
"sroffset": 10,
"continue": "-||"
},
"query": {
"searchinfo": {
"totalhits": 470,
"suggestion": "hastemplate:Infobox_musical_artist dart",
"suggestionsnippet": "hastemplate:Infobox_musical_artist <em>dart</em>"
},
"search": [
{
"ns": 0,
"title": "Daft Punk",
"snippet": "<span class=\"searchmatch\">Daft</span> Punk are an electronic music duo consisting of French musicians Guy-Manuel de Homem-Christo and Thomas Bangalter. The duo achieved significant popularity",
"size": 76278,
"wordcount": 8170,
"timestamp": "2016-02-08T01:33:54Z"
},
...
Here is a CodePen demo: http://codepen.io/slaporte/pen/obmaWY
It still may not capture 100% of the bands on Wikipedia. If there are specific subgenres you are looking for you, you can try using the hastemplate parameter along with links or categories to narrow or expand your search. You can learn more about the other Wikipedia CirrusSearch parameters here.
By the way, this is an interesting approach to autocomplete!
I'm in the process of creating a application using Hot Towel, which supports multiple language (eg. english, french)
I have the referred the following links
Translating Views
Durandal localization example
And my question is how can i render views of application based on user language. If user selects english, the complete application should display contents in english. How to achieve this
I have tried something like in the second link.
define({
'root': {
welcome: 'Welcome!',
flickr: 'Flickr'
},
'fr-fr': true,
'es-es': true,
});
Is this i have to create seperate views for languages or i have to create seperate App folder for contents
Suggest me some best practices.
I don't recommend using separate views or separate folders if your project is a big one.
You can just create a file of the labels and if you use lib like knockout just data-bind these labels once (text: xxxx). In addition you can use i18n to manage labels.
With selected language just load the specific language file to your viewmodel.
EDIT1:
I'd never encountered a complete sample nor tutorial. So how I do is to :
use tools like i18n to get the key-paired dictionary file for labels in html and in some javascript code like messages.
then manually I indexed these labels by augmenting knockout viewmodels for views and variables for modules.
This is my last option in waiting for better solution. Hope this can help!
you can do some thing like this . YOu can change the APP folder if you are need do lot of locale changes you can use the following method
#{
string strAcceptLanguage;
strAcceptLanguage = System.Configuration.ConfigurationManager.AppSettings["Locale"].ToString();
if (strAcceptLanguage == "en-us")
{
#Scripts.Render("~/Scripts/vendor.js")
<script type="text/javascript" src="~/Scripts/require.js" data-main="en-US/main"></script>
}
else if (strAcceptLanguage == "es-es")
{
#Scripts.Render("~/Scripts/vendor.js")
<script type="text/javascript" src="~/Scripts/require.js" data-main="en-UK/main"></script>
}
else if (strAcceptLanguage == "fr-fr")
{
#Scripts.Render("~/Scripts/vendor.js")
<script type="text/javascript" src="~/Scripts/require.js" data-main="AUZ/main"></script>
}
}
in the Index.cshtml you can use the above code and for the you need to have value in Webconfig file
<add key="Locale" value="en-us" />
and in the SPA page each time when the user try to change the locale by pressing button or any kind of option you have to trigger a event to call a AJAX post to assess a REST api to update the Given Locale Value in the webconfig file
changeLocale: function (val) {
var name = JSON.stringify({
locale: val
});
$.ajax({
cache: false,
url: "http://localhost:49589/api/Locale",
type: "POST",
dataType: "json",
data: name,
contentType: "application/json; charset=utf-8",
processData: false,
success: function (json) {
alert(json);
location.reload();
},
error: function (json) {
alert("error" + JSON.stringify(json));
}
});
you have to write the above code in the shell.js and the shell.html has the following code
<div class="btn-group" data-toggle="buttons-radio">
<button type="button" class="btn btn-primary" data-bind="click: changeLocale.bind($data, 'en-us')">English</button>
<button type="button" class="btn btn-primary" data-bind="click: changeLocale.bind($data, 'es-es')">French</button>
<button type="button" class="btn btn-primary" data-bind="click: changeLocale.bind($data, 'fr-fr')">Japanese</button>
</div>
And the rest api like this
[HttpPost]
public string ChangeLocale(Locale l)
{
ConfigurationManager.AppSettings["Locale"] = l.locale;
return "success";
}
hope this will help
I have implemented the google_visualr gem and it works perfectly in development. However when I push to heroku the visualization does not show up. All the javascript is present and there is no error or indication in the app logs.
Here is the javascript that is generated. It's exactly the same as dev. Do i have to do anything additional to get the google visualization to run in heroku environment?
<script type='text/javascript'>
google.load('visualization','1', {packages: ['corechart'], callback: function() {
var data_table = new google.visualization.DataTable();data_table.addColumn('string', 'Status');data_table.addColumn('number', 'Count');data_table.addRow([{v: 'Started Applications'}, {v: 10}]);data_table.addRow([{v: 'Completed Applications'}, {v: 1}]);
var chart = new google.visualization.PieChart(document.getElementById('pie_chart'));
chart.draw(data_table, {width: 360, height: 240, title: 'Applications Status Summary', is3D: true, legend: 'bottom'});
}});
</script>
I found the problem was that my call to the google jsapi was not secure so the browser was blocking the request.
<script src='http://www.google.com/jsapi'></script>
I was able to fix this by requesting the jsapi in secure mode using https
<script src='https://www.google.com/jsapi'></script>
There is nothing additional to be done to get the visualizations to work on Heroku.
The demo site is hosted on Heroku too: http://googlevisualr.herokuapp.com/examples/interactive/pie_chart
Just to check, is this in the head tag, at the top of the page?
<script src='http://www.google.com/jsapi'></script>