How to add special offers to the cart?


Actually the pre-order system works only with the products from the categories you predefined. So in this case we'll just define a new category called 'offers' and will hide it from the slider tabs.

Please follow these steps:

  1. Define a new category called 'offers'. Something similar to this.
  2. Add the category into the 'js/products/categoryList.js' file. Like in the screenshot.
  3. Now you should set the default property 'hidden' for the rest of the categories to false. Open category model and set the 'hidden' attribute to false. See the screenshot.
  4. Hide the hidden category from the tabs. To do so, please open the 'js/products/views/categoryListView.js' and add the if statement when adding the new category, see the screenshot.
  5. Open your 'js/products/products.js' file and search for 'Create category collection' comment.
  6. Add the following lines of code like shown in the screenshot.
  7. Once that's done, please follow the instructions from the screenshot.
  8. Refresh your browser, open your browser's console and pick the correct 'cid's, see the screenshot, you'll have to add these values on your 'Order now' buttons later.
  9. Open your HTML file, go down to your offers and add the 'js-offer' class on every 'order now' button. Once that's done, please pass through them again and add the 'data-target' attribute with the values you've copy pasted previously. See the screenshot.
  10. Bind the click event on those buttons within the 'js/products/products.js' file see the screenshot. Once that function in defined all you have to do is to call that function with the init function, like in the screenshot.
  11. Remove / comment the 'console.log' from the script I've provided, see the screenshot.

If you wrote the correct data-targets, then by clicking on the 'order now' buttons, those offers should be added to the 'cart'.

Tags: offers, special

Last update:
2015-12-07 18:11
Author:
Vlad Sargu
Revision:
1.6
Average rating:0 (0 Votes)