Results 1 to 1 of 1
  1. #1
    Join Date
    Jan 2007
    Posts
    1,484
    Plugin Contributions
    10

    Default please help me fix this code, adding quantity box and add to cart button to xsell

    I have been manipulating and trying everything I can think of - I am a budding coder trying to figure it out- to get this quantity box and add to cart button to the xsells(and any other fields throughout a site) and have run into a brick wall - I simply am too ignorant with php code and logic to figure this out - and I have spent hours and hours tweaking and manipulating trying to get it to work but to no avail. If you go to http://www.drumfactorydirect.com/dru...8/1410c-9.html you will see that if you add any quantity of the main product it will add one of the first xsell products instead. If you add any amount of the other cross sells, besides the first cross sell, it will add the correct amount to the cart but it will redirect to that products' product listing page. If you add any amount to the first cross sell it will add the correct amount and keep you on the same page (which is what I was going for). Here is the code that I have tried, it comes from Paulm who has added many useful contribs. I have tried using the add to cart code from the featured/new/specials listings with partially successful results but the code below has seemed to have gotten closest to what I am trying to achieve which is to keep the customer on the same page while adding more related products to their cart. It seems to have something to do with having 'cart_quantity' in there since the main product listing also uses the same command and the xsell code seems to "bleed" into the main product listing code. I've tried changing the 'cart_quantity' to other values such as 'xsell_quantity' but it doesn't work. Am I on the right track?

    Here's the code so far:

    Code:
    $myBuyNow = '';
    $flag_show_product_info_in_cart_qty = 1;
    $myBuyNow .= zen_draw_form('cart_quantity', zen_href_link(zen_get_info_page($xsell_query->fields['products_id']), zen_get_all_get_params(array('action')) . 'action=add_product&products_id=' . $xsell_query->fields['products_id']), 'post', 'enctype="multipart/form-data"') . "\n";
    $myBuyNow .= 'Quantity' . '<input type="text" name="cart_quantity" value="' . (zen_get_buy_now_qty($xsell_query->fields['products_id'])) . '" maxlength="6" size="4" />' . "\n";
    $myBuyNow .= zen_draw_hidden_field('products_id', $xsell_query->fields['products_id']);
    $myBuyNow .= zen_image_submit(BUTTON_IMAGE_BUY_NOW, BUTTON_BUY_NOW_ALT);
    $myBuyNow .= '</form>';
    $myBuyNow .= (($flag_show_product_info_in_cart_qty == 1 and $_SESSION['cart']->in_cart($xsell_query->fields['products_id'])) ? '<p class="xsellProductsInCart">' . PRODUCTS_ORDER_QTY_TEXT_IN_CART . $_SESSION['cart']->get_quantity($xsell_query->fields['products_id']) . '</p>' : '');
    I'm sure that someone with more php experience than me can correct this in a few minutes. If anyone can please make this work I will happily package it up to put into the downloads section. I think having the ability to add quantities of the xsell products to the cart without leaving the initial page is a huge boon to many people to get extra upsells.

    Can anyone please help me sort this out?

    Thanks!!

    Matt
    Last edited by lankeeyankee; 7 Nov 2007 at 03:30 AM.

 

 

Similar Threads

  1. v151 Style Quantity Box and Add To Cart Button separately
    By k1ra in forum Templates, Stylesheets, Page Layout
    Replies: 4
    Last Post: 29 Nov 2013, 06:49 AM
  2. Help? not in stock, add to cart button gone. How to fix this?
    By Dramacydril in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 3 Feb 2011, 05:05 AM
  3. Separating Quantity Box and Add to Cart button
    By k8ee in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 16 Sep 2010, 03:53 PM
  4. Aligning Quantity Box and Add to Cart Button
    By eyal8r in forum General Questions
    Replies: 14
    Last Post: 24 Feb 2010, 04:32 AM
  5. Adding quantity box to add to cart button on featured, new, specials displays
    By lankeeyankee in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 20 Sep 2007, 11:50 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