Duplicate products added to cart

Questions and answers about ShopSite Custom Templates

Duplicate products added to cart

Postby Kapitol » Tue Jul 10, 2012 12:10 pm

We're having problems with 2 of the same product being added to the cart regardless if you check a sub-product or not. One will always have a zero sum. Take a look on this page to try it for yourself if you are curious. http://www.artandsoulbeads.com/store/crystal_components_rondelles_with_swarovski_chatons.html

Problem 1
I am missing some type of form validation which prevents products being added to the cart without being checked.

Problem 2
The template is also wrong in that it adds 2 products with one having a zero sum.

Problem 3
Tables are off for products but <td>'s are still being added in the generated HTML for products. Is there a VAR.No Table type of command I can use for the sub products?

I am hoping Jim or someone can help me find a script which was built for shopsite to prevent problem 1 from happening.

For anyone who thinks they can help here is my product code.

Code: Select all
#########################
[-- DEFINE SUBPRODUCT --]
[-- VAR.TableLayout no --]
<ul><li><input type="checkbox" name="itemnum" value="[-- PRODUCT.RECORDNUMBER --]">
[-- product.name --]&nbsp; [-- product.price --] </li></ul>

[-- IF PRODUCT.QuantityPricing --]
<div class="QPtable">
[-- PRODUCT.QuantityPricing --]
</div>
[-- END_IF --]
[-- END_DEFINE SUBPRODUCT --]
#############################

#########################
[-- DEFINE PRODUCT_CROSS_SELL --]
[-- INCLUDE Product-Name PROCESS --]
[-- INCLUDE Product-Price PROCESS --]
[-- IF VAR.MoreInfoTemplate --]
  [-- IF PRODUCT.QuantityPricing --]
    <div class="QPtable">
    [-- PRODUCT.QuantityPricing --]
    </div>
  [-- END_IF --]
  [-- IF ANALYTICS_MULTI_DOMAIN --]
  <form action="[-- SHOPPING_CART_URL BASE --]/order.cgi" method="post" onSubmit="javascript:__utmLinkPost(this)">
  [-- ELSE --]
  <form action="[-- SHOPPING_CART_URL BASE --]/order.cgi" method="post">
  [-- END_IF --]
  <input type="hidden" name="storeid" value="[-- STORE_ID --]">
  <input type="hidden" name="dbname" value="products">
  <input type="hidden" name="function" value="add">
  <input type="hidden" name="itemnum" value="[-- PRODUCT.RecordNumber --]">

  [-- IF PRODUCT.DisplayOrderingOptions --]
    [-- IF PRODUCT.OptionText --]
      [-- PRODUCT.OptionText --]
    [-- END_IF --]
    [-- ORDER_OPTION_MENU LINE --]
  [-- END_IF --]

  [-- IF PRODUCT.DisplayOrderQuantity checked --]
    Quantity <input type="text" size="2" name="[-- PRODUCT.RecordNumber --]:qnty" value="1" >&nbsp;&nbsp;
  [-- END_IF --]
  [-- IF VAR.AddButtonGraphic --]
    <input type="image" class="add" src="[-- OUTPUT_DIRECTORY_URL --]/[-- VAR.Media --]/[-- VAR.AddButtonGraphic --]" name="Add to Cart" alt="Add to Cart">
  [-- ELSE_IF ADDIMAGE? --]
    <input type="image" [--ADDIMAGE--]>
  [-- ELSE --]
    <input class="add" type="submit" value="[-- ADDTEXT --]">
  [-- END_IF --]

  </form>
[-- ELSE --]
  [-- PRODUCT.OrderCheckout --]
[-- END_IF --]
[-- END_DEFINE PRODUCT_CROSS_SELL --]
#############################


######################
[-- DEFINE PRODUCT --]
######################
### Set a bunch of variables ###
[-- VAR.TableLayout no --]
#[-- VAR.Form no --]
[-- VAR.Options no --]
[-- VAR.Quantity no --]
[-- VAR.Graphic no --]

### Start the form for Add to Cart button ###
[-- IF ANALYTICS_MULTI_DOMAIN --]
  <form action="[-- SHOPPING_CART_URL BASE --]/order.cgi" method="post" onSubmit="javascript:__utmLinkPost(this)">
[-- ELSE --]
  <form action="[-- SHOPPING_CART_URL BASE --]/order.cgi" method="post">
[-- END_IF --]
<input type="hidden" name="storeid" value="[-- STORE_ID --]">
<input type="hidden" name="dbname" value="products">
<input type="hidden" name="function" value="add">

####################
#  PRODUCT PRICE   #
####################
#PRODUCT GRAPHIC
[-- INCLUDE Product-Graphic PROCESS --]
[-- PRODUCT.Graphic --]
[-- IF PRODUCT.DisplayName --]<div class="name">[-- PRODUCT.Name --]</div>[-- END_IF --]
<span></span>
[-- IF PRODUCT.ProductDescription --]<div class="descr">[-- PRODUCT.ProductDescription --]</div>[-- END_IF --]
#sub
[-- IF PRODUCT.Subproduct --]
    [-- VAR.TableLayout no --]
    [--LOOP SUBPRODUCTS 1 --]
   [--SUBPRODUCTS--]
[--END_LOOP SUBPRODUCTS--]
    [-- ELSE --]
        [-- IF PRODUCT.DisplayPrice --]
        [-- IF PRODUCT.SaleAmount --]
        <div class="price"><strike>[-- PRODUCT.Price --]</strike> <b>[-- PRODUCT.SaleAmount --]</b></div>
    [-- ELSE --]
        <div class="price">[-- PRODUCT.Price --]</div>
    [-- END_IF --]
    [-- END_IF --] 
[-- END_IF --]
[-- IF PRODUCT.QuantityPricing --]
#do nothing
[-- ELSE --]
[-- END_IF --]
<input type="hidden" name="itemnum" value="[-- PRODUCT.RecordNumber --]">
<span></span>
[-- IF PRODUCT.QuantityPricing --]
  <div class="QPtable">
  [-- PRODUCT.QuantityPricing --]
  </div>
[-- END_IF --]
<div class="buttongroup">
[-- IF VAR.AddButtonGraphic --]
  <input type="image" class="add" src="[-- OUTPUT_DIRECTORY_URL --]/[-- VAR.Media --]/[-- VAR.AddButtonGraphic --]" name="Add to Cart" alt="Add to Cart">
[-- ELSE_IF ADDIMAGE? --]
  <input type="image" [--ADDIMAGE--]>
[-- ELSE --]
  <input class="add" type="submit" value="[-- ADDTEXT --]">
[-- END_IF --]
<div></div>
</div>
  </form>
[-- END_DEFINE PRODUCT --]
#############################
[-- DEFINE MORE_INFO_PAGE --]

<!DOCTYPE html>
<html>
<!--[if lt IE 7]> <html class="lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>    <html class="lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>    <html class="lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class=""> <!--<![endif]-->
[-- IF PAGE.Title --]
  <title>[-- PAGE.Title --]</title>
[-- ELSE --]
  <title>[-- PAGE.Name --]</title>
[-- END_IF --]

[-- IF PAGE.MetaKeywords --]
<meta name="keywords" content="[-- PAGE.MetaKeywords --]">
[-- END_IF --]

[-- IF PAGE.MetaDescription --]
<meta name="description" content="[-- PAGE.MetaDescription --]">
[-- END_IF --]

<link rel="stylesheet" type="text/css" href="[-- OUTPUT_DIRECTORY_URL --]/media/ss-bead.css" />
<link rel="stylesheet" type="text/css" href="[-- OUTPUT_DIRECTORY_URL --]/media/reset.css" />
<script type="text/javascript" src="[-- OUTPUT_DIRECTORY_URL --]/media/modernizr.custom.42216.js"></script>
</head>
<body class="-">
<div id="container">
#############################
[-- VAR.MoreInfo "yes" --]
[-- IF VAR.MoreInfoTemplate --]
  [-- INCLUDE VAR.MoreInfoTemplate PROCESS --]
[-- ELSE --]
  [-- INCLUDE Classic-MoreInfoPage PROCESS --]
[-- END_IF --]
[-- VAR.MoreInfo "" --]
</div>
[-- INCLUDE general-footer PROCESS --]

</body>
</html>
[-- END_DEFINE MORE_INFO_PAGE --]
Kapitol
 
Posts: 52
Joined: Mon May 14, 2012 10:26 pm

Re: Duplicate products added to cart

Postby ShopSite Lauren » Tue Jul 10, 2012 12:28 pm

Problem 1 - There is checkbox validation javascript which will check that at least one checkbox is checked. An example of a template using this is the Modern product more information template. I believe it is in an include file called checker.js or something like that (you can look in the modern product template to see how it is setup).

Problem 2 - you want to make sure you are only adding the input for product sku of the parent product IF there are no subproducts. Currently you have the input for sku/itemnum for the parent product as well as the subproducts.

Product 3 - in the [--LOOP SUBPRODUCTS --] tag, you want to remove the number "1" because the "1" tells ShopSite to create 1 subproduct per row, but you don't want rows at all.

Try using the modified template below.
Code: Select all
#########################
    [-- DEFINE SUBPRODUCT --]
    <li><input type="checkbox" name="itemnum" value="[-- PRODUCT.RECORDNUMBER --]">[-- product.name --]&nbsp; [-- product.price --]</li>

    [-- IF PRODUCT.QuantityPricing --]
    <div class="QPtable">
    [-- PRODUCT.QuantityPricing --]
    </div>
    [-- END_IF --]
    [-- END_DEFINE SUBPRODUCT --]
    #############################

    #########################
    [-- DEFINE PRODUCT_CROSS_SELL --]
    [-- INCLUDE Product-Name PROCESS --]
    [-- INCLUDE Product-Price PROCESS --]
    [-- IF VAR.MoreInfoTemplate --]
      [-- IF PRODUCT.QuantityPricing --]
        <div class="QPtable">
        [-- PRODUCT.QuantityPricing --]
        </div>
      [-- END_IF --]
      <form action="[-- SHOPPING_CART_URL BASE --]/order.cgi" method="post">
      <input type="hidden" name="storeid" value="[-- STORE_ID --]">
      <input type="hidden" name="dbname" value="products">
      <input type="hidden" name="function" value="add">
      <input type="hidden" name="itemnum" value="[-- PRODUCT.RecordNumber --]">

      [-- IF PRODUCT.DisplayOrderingOptions --]
        [-- IF PRODUCT.OptionText --]
          [-- PRODUCT.OptionText --]
        [-- END_IF --]
        [-- ORDER_OPTION_MENU LINE --]
      [-- END_IF --]

      [-- IF PRODUCT.DisplayOrderQuantity checked --]
        Quantity <input type="text" size="2" name="[-- PRODUCT.RecordNumber --]:qnty" value="1" >&nbsp;&nbsp;
      [-- END_IF --]
      [-- IF VAR.AddButtonGraphic --]
        <input type="image" class="add" src="[-- OUTPUT_DIRECTORY_URL --]/[-- VAR.Media --]/[-- VAR.AddButtonGraphic --]" name="Add to Cart" alt="Add to Cart">
      [-- ELSE_IF ADDIMAGE? --]
        <input type="image" [--ADDIMAGE--]>
      [-- ELSE --]
        <input class="add" type="submit" value="[-- ADDTEXT --]">
      [-- END_IF --]

      </form>
    [-- ELSE --]
      [-- PRODUCT.OrderCheckout --]
    [-- END_IF --]
    [-- END_DEFINE PRODUCT_CROSS_SELL --]
    #############################


    ######################
    [-- DEFINE PRODUCT --]
    [-- VAR.TableLayout no --]
    [-- VAR.Options no --]
    [-- VAR.Quantity no --]
    [-- VAR.Graphic no --]
    <form action="[-- SHOPPING_CART_URL BASE --]/order.cgi" method="post">
    <input type="hidden" name="storeid" value="[-- STORE_ID --]">
    <input type="hidden" name="dbname" value="products">
    <input type="hidden" name="function" value="add">

    #PRODUCT GRAPHIC
    [-- INCLUDE Product-Graphic PROCESS --]
    [-- PRODUCT.Graphic --]
    [-- IF PRODUCT.DisplayName --]<div class="name">[-- PRODUCT.Name --]</div>[-- END_IF --]
    <span></span>
    [-- IF PRODUCT.ProductDescription --]<div class="descr">[-- PRODUCT.ProductDescription --]</div>[-- END_IF --]
    #sub
    [-- IF PRODUCT.Subproduct --]
        <ul>[--LOOP SUBPRODUCTS --]
       [-- SUBPRODUCTS --]
        [-- END_LOOP SUBPRODUCTS --]</ul>
     [-- ELSE --]
    <input type="hidden" name="itemnum" value="[-- PRODUCT.RecordNumber --]">
            [-- IF PRODUCT.DisplayPrice --]
              [-- IF PRODUCT.SaleAmount --]
            <div class="price"><strike>[-- PRODUCT.Price --]</strike> <b>[-- PRODUCT.SaleAmount --]</b></div>
               [-- ELSE --]
            <div class="price">[-- PRODUCT.Price --]</div>
               [-- END_IF --]
             [-- END_IF --]
    [-- END_IF --]
    [-- IF PRODUCT.QuantityPricing --]
    #do nothing
    [-- ELSE --]
    [-- END_IF --]
    <span></span>
    [-- IF PRODUCT.QuantityPricing --]
      <div class="QPtable">
      [-- PRODUCT.QuantityPricing --]
      </div>
    [-- END_IF --]
    <div class="buttongroup">
    [-- IF VAR.AddButtonGraphic --]
      <input type="image" class="add" src="[-- OUTPUT_DIRECTORY_URL --]/[-- VAR.Media --]/[-- VAR.AddButtonGraphic --]" name="Add to Cart" alt="Add to Cart">
    [-- ELSE_IF ADDIMAGE? --]
      <input type="image" [--ADDIMAGE--]>
    [-- ELSE --]
      <input class="add" type="submit" value="[-- ADDTEXT --]">
    [-- END_IF --]
    <div></div>
    </div>
      </form>
    [-- END_DEFINE PRODUCT --]
    #############################
    [-- DEFINE MORE_INFO_PAGE --]
    <!DOCTYPE html>
    <html>
    <!--[if lt IE 7]> <html class="lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
    <!--[if IE 7]>    <html class="lt-ie9 lt-ie8"> <![endif]-->
    <!--[if IE 8]>    <html class="lt-ie9"> <![endif]-->
    <!--[if gt IE 8]><!--> <html class=""> <!--<![endif]-->
    [-- IF PRODUCT.MoreInformationTitle --]
      <title>[-- PRODUCT.MoreInformationTitle --]</title>
    [-- ELSE --]
      <title>[-- PRODUCT.Name --]</title>
    [-- END_IF --]

    [-- IF PRODUCT.MoreInformationMetaKeywords --]
    <meta name="keywords" content="[-- PRODUCT.MoreInformationMetaKeywords --]">
    [-- END_IF --]

    [-- IF PRODUCT.MoreInformationMetaDescription --]
    <meta name="description" content="[-- PRODUCT.MoreInformationMetaDescription --]">
    [-- END_IF --]

    <link rel="stylesheet" type="text/css" href="[-- OUTPUT_DIRECTORY_URL --]/media/ss-bead.css" />
    <link rel="stylesheet" type="text/css" href="[-- OUTPUT_DIRECTORY_URL --]/media/reset.css" />
    <script type="text/javascript" src="[-- OUTPUT_DIRECTORY_URL --]/media/modernizr.custom.42216.js"></script>
    </head>
    <body class="-">
    <div id="container">
    #############################
    [-- VAR.MoreInfo "yes" --]
    [-- IF VAR.MoreInfoTemplate --]
      [-- INCLUDE VAR.MoreInfoTemplate PROCESS --]
    [-- ELSE --]
      [-- INCLUDE Classic-MoreInfoPage PROCESS --]
    [-- END_IF --]
    [-- VAR.MoreInfo "" --]
    </div>
    [-- INCLUDE general-footer PROCESS --]

    </body>
    </html>
    [-- END_DEFINE MORE_INFO_PAGE --]
- ShopSite Lauren
Contact me for help with any of your
custom ShopSite template questions.
ShopSite Lauren
 
Posts: 887
Joined: Fri Aug 11, 2006 1:35 pm
Location: Orem, UT


Return to Custom Template Questions

Who is online

Users browsing this forum: No registered users and 117 guests