Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
integration:foxycart:multiship_javascript_070 [2010/11/24 05:08] – Removing console.info statements as they are throwing js errors. 98.193.202.154 | integration:foxycart:multiship_javascript_070 [2017/04/26 07:02] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ---- dataentry ---- | + | ---- dataentry |
- | type : integration # do not change this line | + | type : integration #do not change this line |
- | systems | + | systems |
- | name : multiship_jquery_070 # the name of the integration | + | name : multiship_jquery_070+ #the name of the integration |
- | description | + | description |
- | tags_tags | + | tags |
- | date_dt | + | date_dt |
- | version | + | version |
FC version | FC version | ||
- | developer_url : www.foxycart.com # if you'd like a link back to your site, stick it here | + | developer_url : http://www.foxycart.com #if you'd like a link back to your site, stick it here |
---- | ---- | ||
====== multiship javascript ====== | ====== multiship javascript ====== | ||
+ | |||
+ | <WRAP important round> | ||
+ | //**Please note:**// | ||
+ | The code on this page is submitted by members of the FoxyCart community, and may not verified by FoxyCart.com LLC in any way, shape, or form. Please double check the code before installing. If you need help with it please [[http:// | ||
+ | </ | ||
+ | |||
===== Description ===== | ===== Description ===== | ||
Quickly and easily add multiple ship-to addresses to your FoxyCart site by including a single javascript file and adding a few classes to your "add to cart" forms. It looks something like this: | Quickly and easily add multiple ship-to addresses to your FoxyCart site by including a single javascript file and adding a few classes to your "add to cart" forms. It looks something like this: | ||
Line 58: | Line 64: | ||
/* | /* | ||
FoxyCart Multiship Javascript | FoxyCart Multiship Javascript | ||
- | v2.1 | + | v2.4 |
- | 2010-11-16 | + | 2013-03-02 |
INSTRUCTIONS: | INSTRUCTIONS: | ||
Line 74: | Line 80: | ||
jQuery(' | jQuery(' | ||
jQuery(' | jQuery(' | ||
+ | jQuery(' | ||
} | } | ||
Line 100: | Line 107: | ||
jQuery.each(shipto, | jQuery.each(shipto, | ||
// alert(' | // alert(' | ||
- | if (val != ' | + | if (val != ' |
shipto_options += '< | shipto_options += '< | ||
// alert(' | // alert(' | ||
} | } | ||
}); | }); | ||
- | shipto_options += '< | + | if (shipto_options != '' |
} | } | ||
Line 112: | Line 119: | ||
shipto_options += '< | shipto_options += '< | ||
shipto_options += '< | shipto_options += '< | ||
- | shipto_options += '< | + | shipto_options += '< |
// Set the select boxes with the proper values | // Set the select boxes with the proper values | ||
Line 122: | Line 129: | ||
jQuery(this).parents(' | jQuery(this).parents(' | ||
// Set any shipto values. Done this way in case you're adding more than one product at a time. | // Set any shipto values. Done this way in case you're adding more than one product at a time. | ||
- | jQuery(this).parents(' | + | jQuery(this).parents(' |
- | // alert(jQuery(' | + | // alert(jQuery(' |
} else { | } else { | ||
jQuery(this).parents(' | jQuery(this).parents(' | ||
// Set any shipto values. Done this way in case you're adding more than one product at a time. | // Set any shipto values. Done this way in case you're adding more than one product at a time. | ||
- | jQuery(this).parents(' | + | jQuery(this).parents(' |
} | } | ||
- | // console.info(jQuery(' | + | // console.info(jQuery(' |
- | // console.info(jQuery(' | + | // console.info(jQuery(' |
}); | }); | ||
// Finally, select the last used shipto | // Finally, select the last used shipto | ||
if (jQuery.cookie(' | if (jQuery.cookie(' | ||
- | jQuery(' | + | jQuery(' |
} else { | } else { | ||
- | jQuery(' | + | jQuery(' |
} | } | ||
- | + | ||
- | // console.info(jQuery(' | + | // console.info(jQuery(' |
} | } | ||
// Tie any additional product shipto' | // Tie any additional product shipto' | ||
function shipto_multiples() { | function shipto_multiples() { | ||
- | jQuery(' | + | jQuery(' |
- | jQuery(this).parents(' | + | jQuery(this).parents(' |
}); | }); | ||
} | } | ||
Line 159: | Line 166: | ||
// Set the cookie on cart add | // Set the cookie on cart add | ||
- | // NOTE: This does not yet work with multiple forms on the same page. | + | setCookie = function(e, arr) { |
- | // If you need that, chime in on the FoxyCart forums: http:// | + | |
- | setCookie = function() { | + | |
// Run any custom scripts you may have before dealing with, | // Run any custom scripts you may have before dealing with, | ||
// or just insert your code here | // or just insert your code here | ||
Line 170: | Line 175: | ||
var error = false; | var error = false; | ||
var shipto_cookie = jQuery.cookie(' | var shipto_cookie = jQuery.cookie(' | ||
- | var shipto_new = jQuery(' | + | var shipto_new = jQuery(e).find(' |
jQuery.cookie(' | jQuery.cookie(' | ||
jQuery.cookie(' | jQuery.cookie(' | ||
- | if ((shipto_new != ' | + | if ((shipto_new != ' |
jQuery.cookie(' | jQuery.cookie(' | ||
jQuery.cookie(' | jQuery.cookie(' | ||
Line 182: | Line 187: | ||
} | } | ||
- | constructShipTo = function() { | + | constructShipTo = function(e, arr) { |
shipto_initialize(); | shipto_initialize(); | ||
shipto_select(); | shipto_select(); | ||
Line 216: | Line 221: | ||
} | } | ||
// ============================================================================ | // ============================================================================ | ||
- | |||
- | |||
- | |||
// ============================================================================ | // ============================================================================ | ||
- | /** | + | /*! |
- | * Cookie | + | |
- | * | + | |
- | * Copyright (c) 2006 Klaus Hartl (stilbuero.de) | + | |
- | | + | |
- | * http://www.opensource.org/licenses/mit-license.php | + | |
- | * http:// | + | |
* | * | ||
+ | * Copyright 2013 Klaus Hartl | ||
+ | * Released under the MIT license | ||
*/ | */ | ||
- | + | (function(d){" | |
- | /** | + | JSON.stringify(c):String(c);return document.cookie=[e.raw? |
- | * Create a cookie with the given name and value and other optional parameters. | + | d.cookie(a)?(d.cookie(a,"" |
- | * | + | |
- | * @example $.cookie(' | + | |
- | * @desc Set the value of a cookie. | + | |
- | * @example $.cookie(' | + | |
- | * @desc Create | + | |
- | * @example $.cookie(' | + | |
- | * @desc Create | + | |
- | * @example $.cookie(' | + | |
- | * @desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain | + | |
- | | + | |
- | * | + | |
- | * @param String name The name of the cookie. | + | |
- | * @param String value The value of the cookie. | + | |
- | * @param Object options An object literal containing key/value pairs to provide optional cookie attributes. | + | |
- | * @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object. | + | |
- | | + | |
- | | + | |
- | | + | |
- | * @option String path The value of the path atribute of the cookie | + | |
- | * @option String domain The value of the domain attribute of the cookie | + | |
- | * @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will | + | |
- | | + | |
- | * @type undefined | + | |
- | * | + | |
- | * @name $.cookie | + | |
- | * @cat Plugins/Cookie | + | |
- | * @author Klaus Hartl/klaus.hartl@stilbuero.de | + | |
- | */ | + | |
- | + | ||
- | /** | + | |
- | * Get the value of a cookie with the given name. | + | |
- | * | + | |
- | * @example $.cookie(' | + | |
- | * @desc Get the value of a cookie. | + | |
- | * | + | |
- | * @param String name The name of the cookie. | + | |
- | * @return The value of the cookie. | + | |
- | * @type String | + | |
- | * | + | |
- | * @name $.cookie | + | |
- | * @cat Plugins/Cookie | + | |
- | * @author Klaus Hartl/klaus.hartl@stilbuero.de | + | |
- | */ | + | |
- | jQuery.cookie = function(name, value, options) { | + | |
- | | + | |
- | options | + | |
- | | + | |
- | value = ''; | + | |
- | options.expires = -1; | + | |
- | } | + | |
- | var expires = '' | + | |
- | if (options.expires && | + | |
- | var date; | + | |
- | if (typeof options.expires == ' | + | |
- | date = new Date(); | + | |
- | date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000)); | + | |
- | } else { | + | |
- | date = options.expires; | + | |
- | } | + | |
- | | + | |
- | } | + | |
- | // CAUTION: Needed to parenthesize options.path and options.domain | + | |
- | // in the following expressions, otherwise they evaluate to undefined | + | |
- | // in the packed version for some reason... | + | |
- | var path = options.path ? '; path=' | + | |
- | var domain = options.domain ? '; domain=' | + | |
- | var secure = options.secure ? '; secure' | + | |
- | document.cookie = [name, ' | + | |
- | | + | |
- | var cookieValue | + | |
- | if (document.cookie && document.cookie != '' | + | |
- | var cookies | + | |
- | | + | |
- | | + | |
- | // Does this cookie string begin with the name we want? | + | |
- | if (cookie.substring(0, name.length + 1) == (name + ' | + | |
- | cookieValue | + | |
- | break; | + | |
- | } | + | |
- | } | + | |
- | } | + | |
- | return cookieValue; | + | |
- | } | + | |
- | }; | + | |
- | // ============================================================================ | + | |
- | + | ||
- | + | ||
- | + | ||
- | // ============================================================================ | + | |
- | // http:// | + | |
- | /* | + | |
- | * | + | |
- | * Copyright | + | |
- | * Licensed under the MIT License: | + | |
- | * http:// | + | |
- | * | + | |
- | * Addepted to select an option by Mathias Bank (http:// | + | |
- | */ | + | |
- | + | ||
- | /* | + | |
- | * Selects an option by value | + | |
- | * | + | |
- | * @name | + | |
- | * @author | + | |
- | * @param | + | |
- | * @example | + | |
- | * | + | |
- | */ | + | |
- | jQuery.fn.selectOptions | + | |
- | this.each( | + | |
- | function() { | + | |
- | if(this.nodeName.toLowerCase() != "select") return; | + | |
- | + | ||
- | // get number of options | + | |
- | var optionsLength = this.options.length; | + | |
- | + | ||
- | + | ||
- | for(var i = 0; i< | + | |
- | if (this.options[i].value == value) | + | |
- | this.options[i].selected = true; | + | |
- | }; | + | |
- | } | + | |
- | } | + | |
- | ) | + | |
- | return this; | + | |
- | } | + | |
</ | </ | ||
- | |||
- |