Documentation You are here: start » v » 1.0 » javascript

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
v:1.0:javascript [2012/09/26 19:02] – fixing code formatting foxybrettv:1.0:javascript [2017/04/26 07:02] (current) – external edit 127.0.0.1
Line 21: Line 21:
   * ''http://cdn.foxycart.com/YOURDOMAIN/foxycart.js'': Compressed. Includes the code to automatically set your store's domain, your store's FoxyCart domain, and to initialize the ''FC'' object as ''fcc''. Note that the ''preprocess'' and ''process'' events don't actually have any behavior in this version of the file, and that ''postprocess'' is not referenced at all, since ''postprocess'' should be called by whatever ''process'' events you've defined.   * ''http://cdn.foxycart.com/YOURDOMAIN/foxycart.js'': Compressed. Includes the code to automatically set your store's domain, your store's FoxyCart domain, and to initialize the ''FC'' object as ''fcc''. Note that the ''preprocess'' and ''process'' events don't actually have any behavior in this version of the file, and that ''postprocess'' is not referenced at all, since ''postprocess'' should be called by whatever ''process'' events you've defined.
   * ''http://cdn.foxycart.com/YOURDOMAIN/foxycart.raw.js'': Uncompressed. Does not set your store's domain, your store's FoxyCart domain, nor does it initialize the ''fcc'' object. This will generally only be used for special circumstances or advanced users needing access to the uncompressed code.   * ''http://cdn.foxycart.com/YOURDOMAIN/foxycart.raw.js'': Uncompressed. Does not set your store's domain, your store's FoxyCart domain, nor does it initialize the ''fcc'' object. This will generally only be used for special circumstances or advanced users needing access to the uncompressed code.
 +
 +
 ===== What's Different from Previous Versions ===== ===== What's Different from Previous Versions =====
 Almost everything but some of the ways that sessions are set has been rewritten, but here are the main changes from the ''foxycart_includes.js'' in v0.6.0: Almost everything but some of the ways that sessions are set has been rewritten, but here are the main changes from the ''foxycart_includes.js'' in v0.6.0:
Line 33: Line 35:
  
 ===== How It Works & Configuration ===== ===== How It Works & Configuration =====
-While most of this should happen automatically, especially if you're using the ''foxycart.js'' or ''foxycart.complete.js'' versions (as opposed to the ''foxycart.raw.js''), there are a few things that need to be configured correctly.+While most of this should happen automatically, especially if you're using the ''foxycart.js'' or ''foxycart.colorbox.js'' versions (as opposed to the ''foxycart.raw.js''), there are a few things that need to be configured correctly.
  
 ==== ''storedomain'': How Your Links and Forms Are Handled ==== ==== ''storedomain'': How Your Links and Forms Are Handled ====
Line 73: Line 75:
   * ''#fc_total_price'', ''.fc_total_price'': The inner HTML will be replaced by the value in ''FC.json.total_price'', formatted using the ''_currency_format'' function (which adds decimals but doesn't add currency symbols).   * ''#fc_total_price'', ''.fc_total_price'': The inner HTML will be replaced by the value in ''FC.json.total_price'', formatted using the ''_currency_format'' function (which adds decimals but doesn't add currency symbols).
   * ''#fc_singular'', ''.fc_singular'': The inner HTML will be shown if value in ''FC.json.product_count'' is equal to 1, and is hidden otherwise. It can be useful if you want to show "Item/Product" instead of "Items/Products" for ''FC.json.product_count'' = 1.   * ''#fc_singular'', ''.fc_singular'': The inner HTML will be shown if value in ''FC.json.product_count'' is equal to 1, and is hidden otherwise. It can be useful if you want to show "Item/Product" instead of "Items/Products" for ''FC.json.product_count'' = 1.
-  * ''#fc_plural'', ''.fc_plural'': The inner HTML will be shown if value in ''FC.json.product_count'' is greater than 1, and is hidden otherwise.+  * ''#fc_plural'', ''.fc_plural'': The inner HTML will be shown if value in ''FC.json.product_count'' is greater than 1 or less than 1 (zero), and is hidden otherwise.
  
 <code html><a href="https://yourdomain.foxycart.com/cart?cart=view" id="fc_minicart"> <code html><a href="https://yourdomain.foxycart.com/cart?cart=view" id="fc_minicart">
Line 121: Line 123:
   * ''execute'': Execute's all the functions in the array, stopping if ''false'' is returned. (This is mostly an internal method, and won't likely be used by even very advanced integrations.)   * ''execute'': Execute's all the functions in the array, stopping if ''false'' is returned. (This is mostly an internal method, and won't likely be used by even very advanced integrations.)
  
 +
 +If you want to keep the colorbox modal implementation and extend with custom events be sure to add any ''fcc'' customization after that. (You don't need to include both ''foxycart.js'' and ''foxycart.colorbox.js'', as ''foxycart.colorbox.js'' has the entirety of ''foxycart.js'' inside of it already.)
 +<code html><script src="//cdn.foxycart.com/YOURDOMAIN/foxycart.colorbox.js?ver=2" type="text/javascript" charset="utf-8"></script>
 +<script type="text/javascript" charset="utf-8">
 +fcc.events.cart.preprocess.add(function(e, arr) {
 + console.log(arr);
 + return true;
 +});
 +</script></code>
 ==== ''ready'': When the Cart is Ready on Pageload ==== ==== ''ready'': When the Cart is Ready on Pageload ====
 === What It Is === === What It Is ===
Line 223: Line 234:
 ==== ''postprocess'': After the Add-To-Cart ==== ==== ''postprocess'': After the Add-To-Cart ====
 === What It Is === === What It Is ===
-The ''postprocess'' event is //not called directly// by ''foxycart.js'', but is available to use if you need it. This can be useful, for example, if you want to refresh the ''FC.json'' when your modal window is closed, as is the case with the default ''foxycart.complete.js''.+The ''postprocess'' event is //not called directly// by ''foxycart.js'', but is available to use if you need it. This can be useful, for example, if you want to refresh the ''FC.json'' when your modal window is closed, as is the case with the default ''foxycart.colorbox.js''.
 === How It Works: Overview === === How It Works: Overview ===
 Just like the ''preprocess'' and ''process'', you can add multiple functions to the ''postprocess'' even. Notice the call to ''postprocess'' in the ''process'' example above, in the ''onClosed'' parameter. That's telling Colorbox to run the ''postprocess'' events when the modal window is closed. If we add a function like below, then the ''cart_update()'' method will be called (which refreshes the ''FC.json'' and updates the "minicart" helper functions). Just like the ''preprocess'' and ''process'', you can add multiple functions to the ''postprocess'' even. Notice the call to ''postprocess'' in the ''process'' example above, in the ''onClosed'' parameter. That's telling Colorbox to run the ''postprocess'' events when the modal window is closed. If we add a function like below, then the ''cart_update()'' method will be called (which refreshes the ''FC.json'' and updates the "minicart" helper functions).

Site Tools