Page 1 of 3 123 LastLast
Results 1 to 10 of 21
  1. #1
    Join Date
    Nov 2005
    Location
    France
    Posts
    577
    Plugin Contributions
    8

    Default shopping_cart logic - Help please

    I'm porting my first mod from OSC, and i'm trying to work through some code changes that the mod makes to the shopping_cart.php file in OSC. Having done some digging, i've found that zen cart uses two files to create the shopping_cart output. modules\pages\shopping_cart\header_php.php and templates\tpl_shopping_cart_default.php.
    The issue i have is that i don't want to put sql queries in the tpl file, as it appears they belong in the header_php file, but if i put them in there, then i can't get any output from the variables. Am i supposed to be collecting all the information into an array that is passed to the tpl_ file, or is it called in another way?

    Hope that's clear enough.

    Thanks in advance for any advice

    Steve

  2. #2
    Join Date
    Apr 2007
    Location
    Herts. UK
    Posts
    890
    Plugin Contributions
    4

    Default Re: shopping_cart logic - Help please

    Hi,

    The best thing to do is to not add anything to the template or the header but to use an observer/notifier.

    There is a load of information in the wiki....
    http://www.zen-cart.com/wiki/index.p...Observer_Class
    ...including examples that show how to do things with the shopping cart.

    Using an observer/notifier means that your contribution will touch less of the Zen Cart files and be easier to install and work better with upgrades.

    Regards,
    Christian.

  3. #3
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: shopping_cart logic - Help please

    Christian's right - using the observer/notifier system is a less-intrusive way of expanding functionality.

    However, that said, any variables you create in the header_php.php file should still be accessible in the tpl template file for that page. There's no need to use an array to pass data unless it's array-type data. An array is just another variable anyway, so creating another variable shouldn't be a problem.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  4. #4
    Join Date
    Nov 2005
    Location
    France
    Posts
    577
    Plugin Contributions
    8

    Default Re: shopping_cart logic - Help please

    I've had a good read of the info on the Wiki, which is very useful, but leaves me with one question. Using the observer/notifier system, can you insert code in these files to structure the layout of the data that is created, or is it purely for logic code? If it is only for logic code, am i forced to hack core files to format the output as required?

    Thanks
    Steve

  5. #5
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: shopping_cart logic - Help please

    What you'll need to do is really determined by what you want to accomplish -- which you haven't shared.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  6. #6
    Join Date
    Nov 2005
    Location
    France
    Posts
    577
    Plugin Contributions
    8

    Default Re: shopping_cart logic - Help please

    What i'm trying to achieve is a port of the OScommerce Dangling Carrot mod, but with a few enhancements to its functionality. As it runs on OSC, it displays information in the shopping cart to show that you are close to the threshold for a gift, or you have reached the threshold and are now entitled to 'x' product. Modifications to the OSC mod will enable the site owner to set a discounted price for the gift through admin, so if for instance you spend $100 you can have 'y' product for $10 instead of $20. I realise that there are similar ideas presented on the wiki, but they lack the functionality that i am looking to put into the Dangling Carrot module.

    Thanks
    Steve

  7. #7
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: shopping_cart logic - Help please

    Okay.

    What kinds of variables are you adding to the header_php.php that aren't showing up when the template is run? Is "everything" you added not showing up, or just "some" pieces? Perhaps some of your vars aren't echoing what you expected because you're not filling them with information properly ... ie: incorrect syntax on a loop through database results, etc.

    One handy option you have with something like this is to put all your custom variable code into a new file named main_template_vars.php in the same folder as the header_php.php. All your vars can be built there, queries run, etc, and not have to touch the header_php.php file.
    The header file is used mainly to establish prerequisites prior to the templating system kicking in to draw page content. If a page-redirect would be required, you need to know about it in the header_php stage so that no output goes to the browser and thus blocks the redirect etc.
    The one drawback to using a main_template_vars file is that you'll need to manually call the template file at the end of it. Peek at /includes/modules/pages/specials/main_template_vars.php as an example of some queries running and vars being set, and then calling the template file.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  8. #8
    Join Date
    Nov 2005
    Location
    Colorado Springs, CO USA
    Posts
    7,033
    Plugin Contributions
    31

    Default Re: shopping_cart logic - Help please

    Quote Originally Posted by strelitzia View Post
    What i'm trying to achieve is a port of the OScommerce Dangling Carrot mod, but with a few enhancements to its functionality. As it runs on OSC, it displays information in the shopping cart to show that you are close to the threshold for a gift, or you have reached the threshold and are now entitled to 'x' product. Modifications to the OSC mod will enable the site owner to set a discounted price for the gift through admin, so if for instance you spend $100 you can have 'y' product for $10 instead of $20. I realise that there are similar ideas presented on the wiki, but they lack the functionality that i am looking to put into the Dangling Carrot module.

    Thanks
    Steve
    There's this contribution in the downloads section that might be helpful to you.

  9. #9
    Join Date
    Nov 2005
    Location
    France
    Posts
    577
    Plugin Contributions
    8

    Default Re: shopping_cart logic - Help please

    And which mod would that be Clyde as it's not a link :-O

    Might be able to take a peek at the code..see if i can use any of it.

    Thanks

    Steve

  10. #10
    Join Date
    Nov 2005
    Location
    Colorado Springs, CO USA
    Posts
    7,033
    Plugin Contributions
    31

    Default Re: shopping_cart logic - Help please

    Quote Originally Posted by strelitzia View Post
    And which mod would that be Clyde as it's not a link :-O

    Might be able to take a peek at the code..see if i can use any of it.

    Thanks

    Steve
    Sorry 'bout that, here's the link

    Shopping Cart Free-Shipping-Qualifier Sidebox

 

 
Page 1 of 3 123 LastLast

Similar Threads

  1. Need help for bestsellers logic
    By lindanewbie in forum Basic Configuration
    Replies: 0
    Last Post: 24 Mar 2011, 01:52 AM
  2. Please help me with Page Layout Logic?
    By zenHomeboy in forum Templates, Stylesheets, Page Layout
    Replies: 4
    Last Post: 6 Aug 2010, 05:31 PM
  3. Help With Inputting Shipping Logic
    By lmw1 in forum Built-in Shipping and Payment Modules
    Replies: 3
    Last Post: 7 Jun 2009, 02:45 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR