Skip to content

Instantly share code, notes, and snippets.

<!--
This is the default store template file which is used to create new stores. It contains all predefined settings and
products, and even demo orders and customers. Every bit of this template can be replaced when the store is
creating in an API call. The custom template passed in API call should have the same structure, but may only describe
some of the tags. Tags in the custom template replace the corresponding tags in the default template before it
gets applied to store creation. Tags that are missing from the custom template are taken from the default template.
Note that some tags are replaced, not merged, meaning that all the subtag structure is taken from the custom
template, if the custom template specifies the tag.
// Create a state token to prevent request forgery.
// Store it in the session for later validation.
$state = md5(rand());
$app['session']->set('state', $state);
// Set the client ID, token state, and application name in the HTML while
// serving it.
return $app['twig']->render('index.html', array(
'CLIENT_ID' => CLIENT_ID,
'STATE' => $state,
'APPLICATION_NAME' => APPLICATION_NAME
@ndv
ndv / gist:3171909
Created July 24, 2012 19:01
Ecwid 11.0-12.0 CSS diff
@@ -230,7 +230,7 @@
/* 3rd, 4th, etc level categories */
div.ecwid-categories-MenuBarPopup td.gwt-MenuItem {
padding: 3px 40px 3px 10px;
- width: 100%;
+ width: auto;
}
@@ -3250,7 +3250,8 @@
@ndv
ndv / gist:3138496
Created July 18, 2012 19:58
Checkout Widget API: setConfig
EcwidCheckout.setConfig({
currency: {precision:2,roundScale:100,prefix:'$',suffix:'',code:'USD'},
weightUnit: 'POUND',
storeName: 'Test store',
companyEmail: 'sales@example.com',
storeUrl: 'http://www.example.com',
dateFormat: 'MMM d, yyyy',
timeFormat: 'hh:mm a',
timeZone: 'PST'
});
@ndv
ndv / gist:3137982
Created July 18, 2012 18:43
Loading JS API dynamically
window.ControlPanelJSLoaded = function() { EcwidCheckout.init({/* something */}); };
var script = document.createElement('SCRIPT');
script.src = "https://checkout.ecwid.com/controlpanel-api.js";
script.charset = "utf-8";
script.setAttribute("type", "text/javascript");
script.onerror = function() { alert('Could not load script'); };
document.body.appendChild(script);
@ndv
ndv / gist:3136037
Created July 18, 2012 12:50
Checkout Widget API: Initialization
<?php
define('CHECKOUT_WIDGET_OWNERID', 'TEST-123');
define('CHECKOUT_WIDGET_KEY', 'secret');
$timestamp = time();
$signature = hash_hmac( "sha1", CHECKOUT_WIDGET_OWNERID." ".$timestamp, CHECKOUT_WIDGET_KEY);
?>
<script src="https://checkout.ecwid.com/controlpanel-api.js" type="text/javascript" charset="UTF-8"></script>
<script>
@ndv
ndv / gist:3135901
Created July 18, 2012 12:25
CheckoutWidget API: Extension Point Examlpe
<script src="https://checkout.ecwid.com/controlpanel-api.js" type="text/javascript" charset="UTF-8"></script>
<script>
EcwidCheckout.OnChanged.add(function() {
alert("My change event handler");
});
</script>
@ndv
ndv / gist:3135584
Created July 18, 2012 11:04
OnPageLoad
<script src="//app.ecwid.com/script.js?1003" type="text/javascript" charset="UTF-8"></script>
<script>
Ecwid.OnPageLoad.add(function(page) {
alert("My page load handler: "+page.type);
});
</script>
@ndv
ndv / gist:3135544
Created July 18, 2012 10:56
OnAPILoaded usage
<script src="//app.ecwid.com/script.js?1003" type="text/javascript" charset="UTF-8"></script>
<script>
Ecwid.OnAPILoaded.add(function() {
// Ecwid API is available, do something
alert(Ecwid.formatCurrency(123.45));
});
</script>
@ndv
ndv / gist:3135563
Created July 18, 2012 11:03
OnSetProfile
<script src="//app.ecwid.com/script.js?1003" type="text/javascript" charset="UTF-8"></script>
<script>
function dump(arr,level) {
var dumped_text = "";
if (!level) level = 0;
// The padding given at the beginning of the line.
var level_padding = "";
for (var j=0;j<level+1;j++) level_padding += " ";