Results 1 to 7 of 7
  1. #1
    Join Date
    Aug 2013
    Location
    California
    Posts
    22
    Plugin Contributions
    0

    Default why does this code not work?

    PHP Code:
    <?php
    //need to drop an add to cart button here.

    echo zen_draw_form('cart_quantity'zen_href_link(zen_get_info_page($products_id), zen_get_all_get_params(array('action')) . 'action=add_product'$request_type), 'post''enctype="multipart/form-data"');
    ?>
    <input type="hidden" name="cart_quantity" value="<?php echo $qty ?>" maxlength="6" size="4" />
    <input type="hidden" name="products_id" value="<?php echo $products_id ?>" />
    <input type="image" name="image" title=" Add to Cart " src="button_in_cart.gif" alt="Add to Cart " />
    </form>
    Using this form the item adds to cart successfully but never with the correct quantity. What do I need to change to get to the correct quantity?

    EDIT: Changed the img src url for a little more security.
    Last edited by nazca; 4 Oct 2013 at 09:51 PM.

  2. #2
    Join Date
    Feb 2012
    Location
    mostly harmless
    Posts
    1,809
    Plugin Contributions
    8

    Default Re: why does this code not work?

    Quote Originally Posted by nazca View Post
    ... Using this form the item adds to cart successfully but never with the correct quantity. What do I need to change to get to the correct quantity? ...
    Where are you trying to "add" this code?

    Maybe a silly question, but have you verified what value is assigned to the variable $qty?

    The code in the default Zen Cart template for "product_info" already handles automatically showing / hiding the qty based upon the configured settings (can be set on the page for editing a product). You may want to take a peak at the source code for the template ("includes/templates/template_default/templates/tpl_product_info_display.php") and module ("includes/modules/pages/product_info/main_template_vars.php") to see how this works...
    The glass is not half full. The glass is not half empty. The glass is simply too big!
    Where are the Zen Cart Debug Logs? Where are the HTTP 500 / Server Error Logs?
    Zen Cart related projects maintained by lhûngîl : Plugin / Module Tracker

  3. #3
    Join Date
    Aug 2013
    Location
    California
    Posts
    22
    Plugin Contributions
    0

    Default Re: why does this code not work?

    Thanks for the reply.

    $qty echo's correctly if I try it.

    This is for a page where users can type in model numbers without having to go through the rest of the shopping cart. People order from our site and tend to have the same order with always a few but never major changes. This page allows them to quickly add the products to their shopping cart without having to find each one every time. We have thousands of products and it takes more time for them to find each one and add it the regular way than to just type it. Confirm it. start a new one.

    EDIT: $qty is actually displayed above the button. So I know its there.

    Last edited by nazca; 4 Oct 2013 at 10:39 PM.

  4. #4
    Join Date
    Aug 2013
    Location
    California
    Posts
    22
    Plugin Contributions
    0

    Default Re: why does this code not work?

    in fact; I pulled this code from tpl_product_info_display_default.php and just filled it in with my variables.

  5. #5
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: why does this code not work?

    Is therre anything from main_template_vars.php that you also need for your custom page/form?

  6. #6
    Join Date
    Aug 2013
    Location
    California
    Posts
    22
    Plugin Contributions
    0

    Default Re: why does this code not work?

    thanks for the reply, gjh42. The best answer I can think to give from your question is... I dont believe so?

    I was able to make it work like this...

    PHP Code:
    $_SESSION['cart']->add_cart($products_id$qty); 
    wonderfully simple. However some unusual things happen. Because I'm doing that in my tpl_custompage_default.php the cart button at the top right does NOT update on the next page load. I've added a confirm button that sort of remedies this, however their item is now in the cart before they've confirmed it. It just looks right... but is not right.

  7. #7
    Join Date
    Sep 2008
    Posts
    210
    Plugin Contributions
    21

    Default Re: why does this code not work?

    You can open product_info/header_php.php and add this code at the top:

    var_dump($_POST);die('here');

    and you will see value of cart_quantity.
    Our Site: http://zucando.com
    Marketing Plugins: Marketing Modules
    Free Response Templates: Responsive Templates

 

 

Similar Threads

  1. Why doesn't this code I wrote work ?
    By royaldave in forum General Questions
    Replies: 1
    Last Post: 14 Mar 2014, 01:21 PM
  2. v151 my custom jQuery code does not work, why??
    By tlyczko in forum Templates, Stylesheets, Page Layout
    Replies: 12
    Last Post: 27 Dec 2012, 12:09 AM
  3. Why Does this SQL not work?
    By plymgary1 in forum General Questions
    Replies: 5
    Last Post: 7 Jun 2011, 11:24 AM
  4. Why does it not work? Please help!
    By pasb in forum Installing on a Linux/Unix Server
    Replies: 3
    Last Post: 22 Jul 2009, 04:01 PM
  5. Why does this only work in the product listing - CSS puzzle
    By budfox in forum Templates, Stylesheets, Page Layout
    Replies: 4
    Last Post: 27 Feb 2007, 08:28 AM

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