Announcement

Collapse
No announcement yet.

Show/Hide Add to Cart Button

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Show/Hide Add to Cart Button

    Hello, sorry its us again!

    In the site http://www.roksportdarts.co.uk/...

    Were encountering another problem, where the Add to Cart button is either showing for every product, whether in stock or not....or it is showing as "Out Of Stock". Im not 100% sure but I imagine the problem is with the php code at the top of the page, Im not sure where has_stock is generated from, or what I would need to do to generate it.

    The code for the site is (sorry I dont know how to put it in a flashy box!):


    <div style="text-align: center;">
    <div style="text-align: left; margin: 1em auto; width: 50%;">

    <actinic:block if="%3cactinic%3avariable%20name%3d%22IsProductFormUsed%22%20%2f%3e">
    <form method="post" action="<actinic:variable name="OnlineScriptURL" value="Shopping Cart Script URL" />">
    <input type="hidden" name="SID" value="<Actinic:Variable Name="SectionID"/>" />
    <input type="hidden" name="PAGE" value="PRODUCT" />
    <input type="hidden" name="PAGEFILENAME" value="<actinic:variable name="SectionPageName" />" />
    <Actinic:SECTION BLOB='<Actinic:Variable Name="SectionCatFile"/>'/>
    <actinic:block if="%3cactinic%3avariable%20name%3d%22IsHostMode%22%20%2f%3e">
    <!-- Hidden field when in trial mode -->
    <input type="hidden" name="SHOP" value="<Actinic:Variable Name="HiddenFields"/>" />
    </actinic:block>
    </actinic:block>
    <!-- Custom code to check stock levels -->
    <actinic:block php="true" >
    $has_stock = 'false';
    </actinic:block>

    <actinic:block if="%3cactinic%3avariable%20name%3d%22StockLevel%22%20%2f%3e%20%3e%200" >
    <!-- the visible product has stock -->
    <actinic:block php="true" >
    $has_stock = 'true';
    </actinic:block>
    </actinic:block>

    <actinic:block if="%3cactinic%3avariable%20name%3d%22IsProductFormUsed%22%20%2f%3e">

    <form method="post" action="<actinic:variable name="OnlineScriptURL" value="Shopping Cart Script URL" />">
    <input type="hidden" name="SID" value="<Actinic:Variable Name="SectionID"/>" />
    <input type="hidden" name="PAGE" value="PRODUCT" />
    <input type="hidden" name="PAGEFILENAME" value="<actinic:variable name="SectionPageName" />" />
    <Actinic:SECTION BLOB='<Actinic:Variable Name="SectionCatFile"/>'/>
    <actinic:block if="%3cactinic%3avariable%20name%3d%22IsHostMode%22%20%2f%3e">
    <!-- Hidden field when in trial mode -->
    <input type="hidden" name="SHOP" value="<Actinic:Variable Name="HiddenFields"/>" />
    </actinic:block>
    </actinic:block>

    <div class="rok_product_brief">
    <div class="topproductarc"><a name="<Actinic:Variable Name="EncodedProductAnchor"/>"><h5><actinic:variable formatting="font(Name|Arial),bold" encoding="actinic" name="ProductName" /></h5></a></div><br/>
    <div class="rok_product_brief_content">
    <div class="rok_product_brief_price"><actinic:variable name="PriceListRetail" /></div>

    <actinic:block i7f="%3cactinic%3avariable%20name%3d%22IsProductReferenceVisible%22%20%2f%3e" >
    <div><strong>Ref:</strong> <actinic:variable name="ProductReference" /></div>
    </actinic:block>
    <actinic:variable name="ProductImageLayout" />
    <div class="rok_brief_addcart">
    <table>
    <tr>
    <td><actinic:variable name="AttributeList" /> <actinic:variable name="ComponentList" /></td>
    <td>
    <actinic:block if="%3cactinic%3avariable%20name%3d%22IsQuantityPromptHidden%22%20%2f%3e">
    <input type="hidden" name="Q_<actinic:variable name="ProductID"/>" value="<actinic:variable name="DefaultQuantity"/>" />
    </actinic:block>
    </td>
    </tr>
    <tr>
    <td colspan="2" >
    <!-- ROKSPORT CODE TO SHOW/HIDE Add to Cart based on stock -->
    <actinic:block php="true" >
    if ($has_stock == 'false') {
    echo "<span style=\"font-weight: bold; font-size: 8; color: green;\">SORRY OUT OF STOCK</span> <div style=\"display: none;\">";
    }
    </actinic:block>
    <actinic:block if="%3cactinic%3avariable%20name%3d%22IsAddToCartButtonShown%22%20%2f%3e">
    <actinic:variable name="AddToCartButton" />
    </actinic:block>
    <actinic:block php="true" >
    if ($has_stock == 'false') {
    echo '</div>';
    }
    </actinic:block>


    </td>
    </tr>
    <tr><td><actinic:variable name="ExtendedInformationLinks" /></td></tr>
    </table>


    <actinic:variable name="CartError" />

    </div>
    </div>

    </div>
    <actinic:block if="%3cactinic%3avariable%20name%3d%22IsProductFormUsed%22%20%2f%3e">
    </form>

    </actinic:block>
    </div>
    </div>
    Could anyone shed any light on what could be causing it to not work properly?

    I know the page currently looks a bit rubbish btw, Im just trying to perform all the functions before I tidy it all up.

    edit: I forgot to add the cart code is currently commented out on the uploaded website!

    thanks Mike
    http://www.roksport.com
    http://www.roksportsurf.co.uk
    http://www.roksportdarts.co.uk
    http://www.a1rugby.co.uk

    #2
    Why do you need to use php code to do this? The default Actinic product layout is set up to display the Out of Stock message when a product goes out of stock anyway (although you have to upload the site to apply the change)....
    ActiveStock
    On-line, real-time stock control plug-in for Actinic V7, V8 and V9
    **New - Captcha plug-in for your Contact Us form**

    ActiveStock website
    Free 30 Day Trial
    ActiveStock Blog (including a new tutorial on a 'Sort By' function for long section pages)

    Comment


      #3
      Originally posted by rmorrow View Post
      Why do you need to use php code to do this? The default Actinic product layout is set up to display the Out of Stock message when a product goes out of stock anyway (although you have to upload the site to apply the change)....
      I dont know whats causing it, I just assumed that was the problem.

      I tried to use a number of the default layouts but that didnt solve the problem
      http://www.roksport.com
      http://www.roksportsurf.co.uk
      http://www.roksportdarts.co.uk
      http://www.a1rugby.co.uk

      Comment


        #4
        OK....the code is working on pages where I dont have a selection, such as the Flights....(ie theres 1 product, which is stock monitored)

        For products where I have a product page (where the main page isnt stock monitored, and has products hidden below it for every different weight, and these are linked to by using a component and choices) it doesnt work, if I put stock manually into that page then it does work.

        If that makes sense
        http://www.roksport.com
        http://www.roksportsurf.co.uk
        http://www.roksportdarts.co.uk
        http://www.a1rugby.co.uk

        Comment

        Working...
        X