Results 1 to 10 of 10
  1. #1
    Join Date
    Nov 2007
    Location
    Sunny Coast, Australia
    Posts
    3,379
    Plugin Contributions
    9

    Default Show comments field below shopping cart if cart contains certain product model

    Greetings,

    I need to show the comments field just below the shopping cart content but ONLY if the cart contains one certain product model (let's call it model 12345).

    If the cart contains any product which does not have the model attribute "12345", then the comments field should NOT show up below the content of the shopping cart.

    As it stands now, the comments field always shows on the shopping cart page, regardless of model.

    How can this be coded in a simple way?

    ZC 1.3.7.1 with many add-ons
    URL www.frnt.org/zencart

    Just drop something into the cart and you will see the comments field displayed.

    Thanks in advance

    Frank

  2. #2
    Join Date
    Nov 2007
    Location
    Sunny Coast, Australia
    Posts
    3,379
    Plugin Contributions
    9

    Default Re: Show comments field below shopping cart if cart contains certain product model

    anyone please ??

  3. #3
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Show comments field below shopping cart if cart contains certain product model

    Wouldn't that be better done on a per Product basis with TEXT attributes?

    You can just have a general TEXT box like you do, but what if you later need it for another Product ... and then another Product?

    Do you need to just know ... Yes a products_id is in the cart ... or do you need to know how many or anything else?

    There are several functions in the shopping_cart class that can be used to identify the contents ...
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today: v1.5.5]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  4. #4
    Join Date
    Nov 2007
    Location
    Sunny Coast, Australia
    Posts
    3,379
    Plugin Contributions
    9

    Default Re: Show comments field below shopping cart if cart contains certain product model

    Thanks Linda

    I have chosen to use the comments box as it re-appears on the following checkout pages. Customers are then always reminded to enter the details of their prescribing practitioner.

    Basically the store has 2 types of products, Practitioner Only and general retail stuff. There are no plans or reasons to add another product type.

    Also, I opted for the "model" attribute for ease of making a distinction. The field already exists on product details page.

    So, if the cart contains one or more products with model = prac then the box is to appear. If none of the products in the cart is marked as prac then the box should not appear.

    Eventually most non-prac (retail) items will disappear from this shop and will be permanently moved to my retail shop Personal Naturals.

    What I am struggling with is the coding to make the box appear or not appear depending on product in the cart.

    Appreciate your help

    Thanks / Frank

  5. #5
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Show comments field below shopping cart if cart contains certain product model

    You could use this function from the shopping_cart class:
    Code:
      /**
       * Method to check whether a product exists in the cart
       *
       * @param mixed product ID of item to check
       * @return boolean
       */
      function in_cart($products_id) {
    that will return true or false ...
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today: v1.5.5]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  6. #6
    Join Date
    Nov 2007
    Location
    Sunny Coast, Australia
    Posts
    3,379
    Plugin Contributions
    9

    Default Re: Show comments field below shopping cart if cart contains certain product model

    Thanks Linda, will take a look at this during the course of the day and post my results .... if any ....

  7. #7
    Join Date
    Nov 2007
    Location
    Sunny Coast, Australia
    Posts
    3,379
    Plugin Contributions
    9

    Default Re: Show comments field below shopping cart if cart contains certain product model

    I abolished the idea of using the "model" field - too messy etc. and assigned this attribute to relevant products:

    ID Option Name Option Type Option Value
    2 Restricted Read Only Practitioner Details Required !
    It had to be a Read Only attribute as I don't want any dropdowns, radio buttons, text fields or check boxes.

    shows up in database as:

    products_options_id = 2

    products_options_name = Restricted
    example product: Blackmores P.C.I.P. 170tabs

    So, if the cart contains product(s) with products_options_id = 2 the following should come into play:

    (file tpl_shopping_cart_default.php around lines 131-136)

    <!--bof practitioner details-->
    <fieldset class="shipping" id="comments">
    <legend><?php echo TABLE_HEADING_COMMENTS; ?></legend>
    <?php echo zen_draw_textarea_field('comments', '45', '3'); ?>
    </fieldset>
    <!--eof practitioner details-->
    If the cart contains no products with products_options_id = 2 then comments box / legend should not be shown.

    Not being savvy with php coding, how can I achieve this?


    Thanks again

  8. #8
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Show comments field below shopping cart if cart contains certain product model

    Read Only Attributes are just that ... they are for READONLY display on the Product _info page ... as such, they never get added to the cart ...
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today: v1.5.5]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  9. #9
    Join Date
    Nov 2007
    Location
    Sunny Coast, Australia
    Posts
    3,379
    Plugin Contributions
    9

    Default Re: Show comments field below shopping cart if cart contains certain product model

    Thanks Linda

    I have played with the TEXT attribute but it gives customers the option to enter something into the box. The Radio Button attribute also leaves the undesirable comment "please choose" when there really is no choice.

    Hence I played with the READ ONLY attribute .....

  10. #10
    Join Date
    Nov 2007
    Location
    Sunny Coast, Australia
    Posts
    3,379
    Plugin Contributions
    9

    Default Re: Show comments field below shopping cart if cart contains certain product model

    Ok, changed the attribute from "Read Only" to "Radio" and got around the undesired *Please Choose:* by changing includes/languages/english/product_info.php

    from this
    define('TEXT_PRODUCT_OPTIONS', 'Please Choose: ');
    to this
    //define('TEXT_PRODUCT_OPTIONS', 'Please Choose: ');
    define('TEXT_PRODUCT_OPTIONS', 'Please Note: ');
    and saved the file using the override system.

    So I guess the attribute could now be used to control the display of this bit of code:

    <!--bof practitioner details-->
    <fieldset class="shipping" id="comments">
    <legend><?php echo TABLE_HEADING_COMMENTS; ?></legend>
    <?php echo zen_draw_textarea_field('comments', '45', '3'); ?>
    </fieldset>
    <!--eof practitioner details-->
    Again, the box should only appear if the cart contains no products with products_options_id = 2

    Any hints please?

 

 

Similar Threads

  1. Replies: 2
    Last Post: 19 Sep 2010, 01:43 PM
  2. Replies: 2
    Last Post: 24 May 2010, 04:40 PM
  3. Freeshipping it cart contains certain item(s)
    By twdhosting in forum Built-in Shipping and Payment Modules
    Replies: 0
    Last Post: 17 Mar 2008, 06:39 PM
  4. Code to show model number in shopping cart?
    By bugyoutoo in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 14 Mar 2008, 07:17 AM
  5. how do i show model # in shopping cart
    By flowerguy in forum Templates, Stylesheets, Page Layout
    Replies: 8
    Last Post: 18 Nov 2006, 09:24 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