Results 1 to 5 of 5
  1. #1
    Join Date
    Sep 2008
    Location
    Cleethorpes
    Posts
    1,227
    Plugin Contributions
    6

    red flag Different Stylesheets

    I've applied this:

    https://www.zen-cart.com/showthread....ory-stylesheet

    Which works very well as I need different sections of my site that have different colours.

    What I am wondering is, is there some way of applying the styles to the cart pages for different sections, so when a customer adds to cart it doesn't change back to the 'base' colour and sticks to the new stylesheet rules set out in my category stylesheet c_xxx.css
    Nick Smith - Venture Design and Print
    https://venturedesignandprint.co.uk

  2. #2
    Join Date
    Jul 2012
    Posts
    16,734
    Plugin Contributions
    17

    Default Re: Different Stylesheets

    So fated reply... Anything is possible.

    It is particularly easier if you have no linked product, because then every product only exists in one category, and then you can apply css to each product that incorporates the master_categories_id of the product.

    The problem comes with product that are linked (single products_id available from more than one category). At this time, when adding a product to the shopping cart, the category id is "lost" regarding the product and therefore, if you have this product in two different categories, the stylesheets for the two different categories result in some "specific" difference, then without the "purchased from" category identified, only the master_category_id category information is available and this may result in the "wrong" stylesheet being applied.

    That said, if the purchased from category doesn't matter or the product does or can only exist in one category there are a couple of straight forward ways to obtain the master_category_id of a product. The first is somewhat obvious to consider as it minimizes the lookup needed for a single query. There may be reason/efficiency by performing a "larger" lookup, but I would say that simply depends on the needs of the code.

    1) the function zen_get_products_category_id($products_id)
    2) the function zen_products_lookup($product_id, 'master_category_id')

    If, as the question implies, it is necessary to know from which category the product was purchased, then additional data must be captured along the add-to-cart process so that the 'purchased from' category can be used to hone in the data needed/wanted in order to eliminate the differences of concern.

    Of course, will have to also incorporate each of your individual category style sheet "rules" into this master shopping_cart stylesheet either by loading in of those sheets or tried and true copy and paste.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  3. #3
    Join Date
    Sep 2008
    Location
    Cleethorpes
    Posts
    1,227
    Plugin Contributions
    6

    red flag Re: Different Stylesheets

    Quote Originally Posted by mc12345678 View Post
    So fated reply... Anything is possible.

    It is particularly easier if you have no linked product, because then every product only exists in one category, and then you can apply css to each product that incorporates the master_categories_id of the product.

    The problem comes with product that are linked (single products_id available from more than one category). At this time, when adding a product to the shopping cart, the category id is "lost" regarding the product and therefore, if you have this product in two different categories, the stylesheets for the two different categories result in some "specific" difference, then without the "purchased from" category identified, only the master_category_id category information is available and this may result in the "wrong" stylesheet being applied.

    That said, if the purchased from category doesn't matter or the product does or can only exist in one category there are a couple of straight forward ways to obtain the master_category_id of a product. The first is somewhat obvious to consider as it minimizes the lookup needed for a single query. There may be reason/efficiency by performing a "larger" lookup, but I would say that simply depends on the needs of the code.

    1) the function zen_get_products_category_id($products_id)
    2) the function zen_products_lookup($product_id, 'master_category_id')

    If, as the question implies, it is necessary to know from which category the product was purchased, then additional data must be captured along the add-to-cart process so that the 'purchased from' category can be used to hone in the data needed/wanted in order to eliminate the differences of concern.

    Of course, will have to also incorporate each of your individual category style sheet "rules" into this master shopping_cart stylesheet either by loading in of those sheets or tried and true copy and paste.
    Ok well the products only apply to the category they are in, they are not linked or duplicated to other categories and won't be in the future. And they won't be applied as a cross sale. They will just sit in the category they exist in, so no need to worry about other categories apart from the actual parent and child categories for the stylesheet.

    Say the rest of the shop as a whole is styled in blue, but the category a customer purchases from is red. What I want to know is the exact code which would need to be implemented in order for the shopping cart pages to remain red all the way through to cart purchase completion, rather than customer adds to cart, and the cart pages change back to blue.
    Nick Smith - Venture Design and Print
    https://venturedesignandprint.co.uk

  4. #4
    Join Date
    Jul 2012
    Posts
    16,734
    Plugin Contributions
    17

    Default Re: Different Stylesheets

    There are several different ways that come to mind.

    Setting a session variable upon addition of the product from the category that has the special css.
    Reviewing the cart contents on each applicable page load to identify if the effect category is present.
    Javascript to be loaded and effect the page (though in a case where javascript is not enabled on the client side, this will have no effect)

    What happens if a product from two different "special" categories is in the cart?

    Regardless the method, then the result needs to be imposed on each potential subsequent page that could be involved or gone to after being on the "special category" and adding such product to the cart.

    Consideration should be given also to how things will look after the purchase is complete, the customer returns to the site and the cart no longer has product in it.

    What about the next time the customer logs in?
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  5. #5
    Join Date
    Sep 2008
    Location
    Cleethorpes
    Posts
    1,227
    Plugin Contributions
    6

    Default Re: Different Stylesheets

    Quote Originally Posted by mc12345678 View Post
    There are several different ways that come to mind.

    Setting a session variable upon addition of the product from the category that has the special css.
    Reviewing the cart contents on each applicable page load to identify if the effect category is present.
    Javascript to be loaded and effect the page (though in a case where javascript is not enabled on the client side, this will have no effect)

    What happens if a product from two different "special" categories is in the cart?

    Regardless the method, then the result needs to be imposed on each potential subsequent page that could be involved or gone to after being on the "special category" and adding such product to the cart.

    Consideration should be given also to how things will look after the purchase is complete, the customer returns to the site and the cart no longer has product in it.

    What about the next time the customer logs in?
    Ok you have maybe gathered this is an alternative solution to having three separate carts (one checkout) - which fell over in the thread you was commenting on previously. I am just thinking I may have an overall colour and just do the cats in the different colours. That would get around difficult issues and it doesn't matter that much as the cart/website has a theme around four colours and then there's a fifth 'BASE' colour - four colours for four sections and then anything out of those sections is the fifth colour if that makes sense? I could use the fifth colour for the none category pages such as the cart.
    Nick Smith - Venture Design and Print
    https://venturedesignandprint.co.uk

 

 

Similar Threads

  1. setting different stylesheets per language
    By davidnelband in forum Templates, Stylesheets, Page Layout
    Replies: 4
    Last Post: 16 Mar 2011, 11:30 PM
  2. How can I get 3 languages associated with 3 different templates & stylesheets?
    By local1970 in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 13 May 2009, 10:54 AM
  3. Multiple stylesheets for different browsers!
    By Shotgun Front in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 18 Apr 2008, 02:26 PM
  4. 2 different stylesheets
    By raimond in forum Templates, Stylesheets, Page Layout
    Replies: 5
    Last Post: 7 Mar 2007, 03:47 PM
  5. 2 Stylesheets
    By DanAllkins in forum Templates, Stylesheets, Page Layout
    Replies: 8
    Last Post: 20 Oct 2006, 02:37 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