Skip to content

Instantly share code, notes, and snippets.

@makfruit
makfruit / ecwid_add_product.js
Last active August 29, 2015 14:05 — forked from genee19/new_gist_file
A simple JS snippet to add product to the cart using Ecwid Javascript API
var product = {
id: 10,
quantity: 3,
options: {
someTextOption: "optionVal",
someDateOption: new Date().getTime().toString(),
someRadioOption: "optionVal",
someDropDownOption: "optionVal",
someCheckboxOption: ["optionVal1", "optionVal2"]
},
@makfruit
makfruit / ecwid_move_cat_descr_and_subcats_below_products.html
Created April 8, 2015 18:33
An HTML/JS snippet for Ecwid to move category description and subcategories under the subcategories/products listing
<!--
An HTML/JS snippet for Ecwid to move category description and subcategories under the subcategories/products listing
https://gist.github.com/makfruit/8f55e57945de9089a014
Put this code after Ecwid integration code on your site
-->
<script src="//code.jquery.com/jquery.min.js"></script>
<script>
Ecwid.OnPageLoaded.add(function(page) {
if (page.type == 'CATEGORY') {
@makfruit
makfruit / ecwid_category_redirects.js
Created November 17, 2011 13:27
A drop-in script for Ecwid to redirect a store visitor to external web pages after they open some categories.
<script>
// categoryURLs array as category Id => redirection URL
// Please use this array to define your own redirection rules
var categoryURLs = {
'1765387' : 'http://www.google.com',
'1797366' : 'http://www.ecwid.com'
};
// Add handler for Ecwid's OnPageLoad event
if (
@makfruit
makfruit / show_ecwid_catalog.php
Created February 9, 2012 10:11
Hide prices for particular categories in Inline SEO catalog
<?php
function show_ecwid_catalog($ecwid_store_id) {
include_once "ecwid_product_api.php";
$ecwid_store_id = intval($ecwid_store_id);
$api = new EcwidProductApi($ecwid_store_id);
$cat_id = isset($_GET['ecwid_category_id']) ? intval($_GET['ecwid_category_id']) : false;
$prod_id = isset($_GET['ecwid_product_id']) ? intval($_GET['ecwid_product_id']) : false;
$ecwid_category_id = $cat_id;
@makfruit
makfruit / ecwid_vk_widgets.js
Created February 21, 2012 13:46
A script for Ecwid to display Vkontakte social widgets on the product pages
/*
* A script for Ecwid to display Vkontakte social widgets (like, share, comments) on the product pages.
* Please include it after the Ecwid integration code.
*
* Required: Ecwid Product API, Vkontakte API, jQuery
*
* Global variables: vkWidgetsSettings (redefines the default widget settings)
*/
/*
@makfruit
makfruit / ecwid_lock_share_panel.js
Created May 16, 2012 14:14
A drop-in script for Ecwid to have the share buttons panel to display at all times (so that a customer doesn't have to click or mouse-over it)
<script>
/*
A drop-in script for Ecwid to have the share buttons panel to display at all times (so that a customer doesn't have to click or mouse-over it).
NOTE: jQuery is required
*/
if (!jQuery.browser.msie && typeof(Ecwid) == 'object') {
Ecwid.OnPageLoaded.add(function(page) {
if ('PRODUCT' == page.type) {
jQuery('.ecwid-productBrowser-sharePanel-header').hide().closest('table').trigger('mouseover').bind('mouseout', function() {
jQuery(this).trigger('mouseover');
@makfruit
makfruit / ecwid_pb_redirection.js
Created August 1, 2012 08:32
A drop-in script for Ecwid for redirection a visitor from featured products page to the main store page
<script>
var ecwid_ProductBrowserURL = 'http://www.example.com'; // change it to your store page URL
if (typeof(Ecwid) == 'object') {
// Add handler for Ecwid's OnPageLoad event
Ecwid.OnPageLoad.add(function(page) {
// If any Ecwid link is clicked, open the corresponding Ecwid page in the main product browser
if (window.location.hash.match(/\/~\//) !== null) {
window.location = ecwid_ProductBrowserURL + window.location.hash;
}
});
@makfruit
makfruit / ecwid_hide_payment_option.js
Created November 21, 2012 12:24
Hide or show payment methods in Ecwid depending on the order total (source: https://gist.github.com/2894819)
/*yepnope1.5.x|WTFPL*/
(function(a,b,c){function d(a){return"[object Function]"==o.call(a)}function e(a){return"string"==typeof a}function f(){}function g(a){return!a||"loaded"==a||"complete"==a||"uninitialized"==a}function h(){var a=p.shift();q=1,a?a.t?m(function(){("c"==a.t?B.injectCss:B.injectJs)(a.s,0,a.a,a.x,a.e,1)},0):(a(),h()):q=0}function i(a,c,d,e,f,i,j){function k(b){if(!o&&g(l.readyState)&&(u.r=o=1,!q&&h(),l.onload=l.onreadystatechange=null,b)){"img"!=a&&m(function(){t.removeChild(l)},50);for(var d in y[c])y[c].hasOwnProperty(d)&&y[c][d].onload()}}var j=j||B.errorTimeout,l=b.createElement(a),o=0,r=0,u={t:d,s:c,e:f,a:i,x:j};1===y[c]&&(r=1,y[c]=[]),"object"==a?l.data=c:(l.src=c,l.type=a),l.width=l.height="0",l.onerror=l.onload=l.onreadystatechange=function(){k.call(this,r)},p.splice(e,0,u),"img"!=a&&(r||2===y[c]?(t.insertBefore(l,s?null:n),m(k,j)):y[c].push(l))}function j(a,b,c,d,f){return q=0,b=b||"j",e(a)?i("c"==b?v:u,a,b,this.i++,c,d,f):(p.splice(this.i++,0,a),1==p.length&&h()),this}function k(){v
@makfruit
makfruit / ecwid_clear_billing_form.html
Created November 30, 2012 14:05
An HTML/Javascript snippet for Ecwid to clear billing form inputs after the 'My billing address is the same as shipping' checkbox is un-ticked
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script>
if (typeof(Ecwid) == 'object') {
// Add handler for Ecwid's OnPageLoad event
Ecwid.OnPageLoaded.add(function(page) {
if ('CHECKOUT_PAYMENT_DETAILS' == page.type) {
jQuery('.ecwid-AddressForm input[type=checkbox]').first().click(function() {
if (!this.checked) {
jQuery('.ecwid-AddressForm input[type=text]').val('');
}
@makfruit
makfruit / ecw_get_productid.js
Created December 13, 2011 06:40
A script for Ecwid to determine a product ID of a product page being displayed
// Add handler for Ecwid's OnPageLoad event
if (
typeof(Ecwid) == 'object'
&& typeof(Ecwid.OnPageLoad) == 'object'
) {
Ecwid.OnPageLoad.add(function(page) {
// Determine a product ID and do necessary actions
if (
typeof(page) == 'object'
&& 'PRODUCT' == page.type