-
- 788 Posts
The beginning of the documentation effort has started here:
http://wiki.modxcms.com/index.php/GCart
Jesse R.
Consider trying something new and extraordinary.
Illinois Wine
Have you considered donating to MODx lately?
Donate now. Every contribution helps.
-
- 788 Posts
Right now on the page load, I iterate through the entire cart array three times. Once to add the items from the temp cart represented as an array into the gCart object that is passed to the Checkout API. Another time for a discount function I built. Last, another time to template the output. I think this needs to be refactored to make it more efficient. Any tips would be welcome.
Jesse R.
Consider trying something new and extraordinary.
Illinois Wine
Have you considered donating to MODx lately?
Donate now. Every contribution helps.
-
- 788 Posts
Jesse R.
Consider trying something new and extraordinary.
Illinois Wine
Have you considered donating to MODx lately?
Donate now. Every contribution helps.
-
- 4,205 Posts
Congratulations. Nice to see the results of some hard work.
-
- 788 Posts
Definitely. And I look forward to feedback from anyone trying to implement it.
Jesse R.
Consider trying something new and extraordinary.
Illinois Wine
Have you considered donating to MODx lately?
Donate now. Every contribution helps.
-
- 898 Posts
Quote from: Jesse at Dec 14, 2007, 07:42 PM
Right now on the page load, I iterate through the entire cart array three times. Once to add the items from the temp cart represented as an array into the gCart object that is passed to the Checkout API. Another time for a discount function I built. Last, another time to template the output. I think this needs to be refactored to make it more efficient. Any tips would be welcome.
Jesse,
Would this work:
- iterate through array once and build multidimensinal array such as
[cart][item1][item_options_for_gcart]
[cart][item1][discount]
[cart][item1][template]
[cart][item2][item_options_for_gcart]
[cart][item2][discount]
[cart][item2][template]
or:
[cart][item_options_for_gcart][item1]
[cart][item_options_for_gcart][item2]
[cart][item_options_for_gcart][item3]
[cart][discount][item1]
[cart][discount][item2]
[cart][discount][item3]
[cart][template][item1]
[cart][template][item2]
[cart][template][item3]
or you could set these as objects. But then you can just iterate through the array items needed in each function (such as gcart, discount, template)
Is this a good idea or is it goofy?
-
- 788 Posts
I took the multidimensional array path, and eliminated the iteration. I will likely do something similar to eliminate the iteration for templating too. The object idea was what I thought of first, but objects cannot be stored in sessions without getting messy.
Jesse R.
Consider trying something new and extraordinary.
Illinois Wine
Have you considered donating to MODx lately?
Donate now. Every contribution helps.
-
- 1,611 Posts
Why do you need to loop through the array again for the templating?
-
- 788 Posts
I don’t, and that is why I plan on removing that iteration. It was just sloppy coding.
Jesse R.
Consider trying something new and extraordinary.
Illinois Wine
Have you considered donating to MODx lately?
Donate now. Every contribution helps.