Created
April 19, 2013 10:22
-
-
Save makfruit/5419458 to your computer and use it in GitHub Desktop.
An HTML/Javascript code snippet for Ecwid to disallow purchasing of products from certain categories
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> | |
| <script type="text/javascript"> | |
| /* An HTML/Javascript code snippet for Ecwid to disallow purchasing of products from certain categories */ | |
| if (typeof(Ecwid) == 'object') { | |
| Ecwid.OnAPILoaded.add(function() { | |
| var __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; | |
| var categories = [ | |
| 1234567, | |
| 5286250 | |
| ]; | |
| Ecwid.OnPageLoaded.add(function(page) { | |
| if (__indexOf.call(categories, page.categoryId) >= 0) { | |
| switch (page.type) { | |
| case 'PRODUCT': | |
| // Hide quantity panel and Add to bag button | |
| jQuery('.ecwid-AddToBagButton').hide(); | |
| jQuery('.ecwid-productBrowser-details-qtyPanel').hide(); | |
| break; | |
| case 'CATEGORY': | |
| // Hide Add to bag links and Buy now buttons | |
| jQuery('.ecwid-productBrowser-productsTable-buy').hide(); | |
| jQuery('.ecwid-AccentedButton').hide(); | |
| break; | |
| } | |
| } | |
| }); | |
| }); | |
| } | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment