Announcement

Collapse
No announcement yet.

Quantity from dropdown with dynamic pricing

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

    Quantity from dropdown with dynamic pricing

    Client wishes quantity selectable from dropdown with dynamic pricing.

    v12 AUG gives the previous versions' advice on dropdown with no mention of dynamic pricing (page 62)

    I have tried to adapt the code without success:
    Code:
    <select name="Q_<actinic:variable name="ProductReference" />"  <actinic:block if="%3cactinic%3avariable%20name%3d%22UseDynamicPrices%22%20%2f%3e%20%3d%3d%20TRUE%20AND%20%3cactinic%3avariable%20name%3d%22IsHostMode%22%20%2f%3e%20%3d%3d%20FALSE%20AND%20%3cactinic%3avariable%20name%3d%22IsPreviewMode%22%20%2f%3e%20%3d%3d%20FALSE" >onpaste="QuantityChanged(this, '<actinic:variable name="DynamicPriceCGIURL" />', <actinic:variable name="SectionID" />)" onkeyup="QuantityChanged(this, '<actinic:variable name="DynamicPriceCGIURL" />', <actinic:variable name="SectionID" />)"</actinic:block><actinic:block if="%3cactinic%3avariable%20name%3d%22UseDynamicPrices%22%20%2f%3e%20%3d%3d%20TRUE%20AND%20%3cactinic%3avariable%20name%3d%22IsHostMode%22%20%2f%3e%20%3d%3d%20TRUE%20AND%20%3cactinic%3avariable%20name%3d%22IsPreviewMode%22%20%2f%3e%20%3d%3d%20FALSE" >onpaste="QuantityChanged(this, '<actinic:variable name="DynamicPriceCGIURL" />', <actinic:variable name="SectionID" />, '<actinic:variable name="ShopID" />')" onkeyup="QuantityChanged(this, '<actinic:variable name="DynamicPriceCGIURL" />', <actinic:variable name="SectionID" />, '<actinic:variable name="ShopID" />')"</actinic:block>/>
    <option selected value="<actinic:variable name="DefaultQuantity" />" />1</option>
    <option value="2">2</option>
    <option value="3">3</option>
    <option value="4">4</option>
    <option value="5">5</option>
    <option value="6">6</option>
    <option value="7">7</option>
    <option value="8">8</option>
    <option value="9">9</option>
    </select>
    Does not work.
    Neither does this:
    Code:
    <select name="Q_<actinic:variable name="ProductReference" />" />
    <option selected value="<actinic:variable name="DefaultQuantity" />"  <actinic:block if="%3cactinic%3avariable%20name%3d%22UseDynamicPrices%22%20%2f%3e%20%3d%3d%20TRUE%20AND%20%3cactinic%3avariable%20name%3d%22IsHostMode%22%20%2f%3e%20%3d%3d%20FALSE%20AND%20%3cactinic%3avariable%20name%3d%22IsPreviewMode%22%20%2f%3e%20%3d%3d%20FALSE" >onpaste="QuantityChanged(this, '<actinic:variable name="DynamicPriceCGIURL" />', <actinic:variable name="SectionID" />)" onkeyup="QuantityChanged(this, '<actinic:variable name="DynamicPriceCGIURL" />', <actinic:variable name="SectionID" />)"</actinic:block><actinic:block if="%3cactinic%3avariable%20name%3d%22UseDynamicPrices%22%20%2f%3e%20%3d%3d%20TRUE%20AND%20%3cactinic%3avariable%20name%3d%22IsHostMode%22%20%2f%3e%20%3d%3d%20TRUE%20AND%20%3cactinic%3avariable%20name%3d%22IsPreviewMode%22%20%2f%3e%20%3d%3d%20FALSE" >onpaste="QuantityChanged(this, '<actinic:variable name="DynamicPriceCGIURL" />', <actinic:variable name="SectionID" />, '<actinic:variable name="ShopID" />')" onkeyup="QuantityChanged(this, '<actinic:variable name="DynamicPriceCGIURL" />', <actinic:variable name="SectionID" />, '<actinic:variable name="ShopID" />')"</actinic:block> />1</option>
    <option value="2">2</option>
    <option value="3">3</option>
    <option value="4">4</option>
    <option value="5">5</option>
    <option value="6">6</option>
    <option value="7">7</option>
    <option value="8">8</option>
    <option value="9">9</option>
    </select>
    Please can anyone advise on making dynamic pricing work with drop down quantity box?

    Thank you!
    Jonathan Chappell
    Website Designer
    SellerDeck Website Designer
    Actinic to SellerDeck upgrades
    Graphicz Limited - www.graphicz.co.uk

    #2
    Jonathan,

    When you are trying to trigger a javascript action from a drop-down being selected you need to handle the "onchange" event of the <SELECT> tag i.e. you need the javscript to be in the SELECT tag AND you need to change the Javascript event to "onchange" from "onpaste" and "onkeyup"
    Also, your quantity field "name" should use "ProductID" and not "ProductRef".

    e.g. try the following instead.
    Code:
    <select name="Q_<actinic:variable name="ProductID" />"  <actinic:block if="%3cactinic%3avariable%20name%3d%22UseDynamicPrices%22%20%2f%3e%20%3d%3d%20TRUE%20AND%20%3cactinic%3avariable%20name%3d%22IsHostMode%22%20%2f%3e%20%3d%3d%20FALSE%20AND%20%3cactinic%3avariable%20name%3d%22IsPreviewMode%22%20%2f%3e%20%3d%3d%20FALSE" >onchange="QuantityChanged(this, '<actinic:variable name="DynamicPriceCGIURL" />', <actinic:variable name="SectionID" />)"</actinic:block><actinic:block if="%3cactinic%3avariable%20name%3d%22UseDynamicPrices%22%20%2f%3e%20%3d%3d%20TRUE%20AND%20%3cactinic%3avariable%20name%3d%22IsHostMode%22%20%2f%3e%20%3d%3d%20TRUE%20AND%20%3cactinic%3avariable%20name%3d%22IsPreviewMode%22%20%2f%3e%20%3d%3d%20FALSE" >onchange="QuantityChanged(this, '<actinic:variable name="DynamicPriceCGIURL" />', <actinic:variable name="SectionID" />, '<actinic:variable name="ShopID" />')"</actinic:block>  />
    <option selected value="1">1</option>
    <option value="2">2</option>
    <option value="3">3</option>
    <option value="4">4</option>
    <option value="5">5</option>
    <option value="6">6</option>
    <option value="7">7</option>
    <option value="8">8</option>
    <option value="9">9</option>
    </select>
    Fergus Weir - teclan ltd
    Ecommerce Digital Marketing

    SellerDeck Responsive Web Design

    SellerDeck Hosting
    SellerDeck Digital Marketing

    Comment


      #3
      Thanks Fergus - I knew I would be displaying my lack of knowledge.

      Perhaps Sellerdeck can include your modification in the AUG?

      Here it is working - fabulous!

      http://www.graphicz.gb.com/generic/a...ml#SID=1#SID=1
      Jonathan Chappell
      Website Designer
      SellerDeck Website Designer
      Actinic to SellerDeck upgrades
      Graphicz Limited - www.graphicz.co.uk

      Comment


        #4
        I am afraid my php/javascript is not up to much.:

        You can display:
        RRP Price
        Your Price
        You save

        Thus
        Code:
        RRP £<actinic:variable name="RRP" /><br />
        <actinic:block if="%3cactinic%3avariable%20name%3d%22IsCustomerMessageUsed%22%20%2f%3e" >
        			<p class="product-price">
        				<Actinic:PRICE_EXPLANATION PROD_REF="<actinic:variable name="ProductID" />" COMPONENTID=-1><actinic:variable name="RetailCustomerMessage" /></Actinic:PRICE_EXPLANATION>
        			</p>
        		</actinic:block>
        		<actinic:block if="%3cactinic%3avariable%20name%3d%22PriceIsEnabled%22%20%2f%3e" >
        			<p class="product-price">
        				<Actinic:PRICES PROD_REF="<actinic:variable name="ProductID" />" RETAIL_PRICE_PROMPT="<actinic:variable name="ProductPriceDescription" />">
        				<actinic:variable name="PriceListRetail" />
        				</Actinic:PRICES>
        			<actinic:block if="%3cactinic%3avariable%20name%3d%22UseDynamicPrices%22%20%2f%3e%20%3d%3d%20true%20AND%20%3cactinic%3avariable%20name%3d%22ProductComponentCount%22%20%2f%3e%20%3d%3d%200" >
        				<actinic:variable name="ProductJavascriptLayout" />
        			</actinic:block>
        			<actinic:variable name="DynamicPrice" />
        			</p>
        		</actinic:block>
        		<actinic:block if="%3cactinic%3avariable%20name%3d%22ProductPriceIsEnabled%22%20%2f%3e%20%3d%3d%20False" >
        			<p class="product-price">
        				<Actinic:NOTINB2B><actinic:variable name="ProductPriceNotEnabledMessage" /></Actinic:NOTINB2B>
        			</p>
        		</actinic:block>
        <span style="color:red;">		
        <actinic:block php="true">
        $rrp = <actinic:variable name="RRP" selectable="false" />;
        $rawprice = <actinic:variable name="ProductPriceRaw" selectable="false" />;
        $rawprice = $rawprice * 1.2; // add in vat if showing VAT inc prices
        // only display is we have an RRP and there's a saving to show
        if ( ($rrp != 0) && ($rrp > $rawprice) )
        {
        $saveprice = round($rrp - $rawprice);
        echo "you save £$saveprice";
        }
        </actinic:block></span>
        Can the 'onchange' event used by Fergus above generate a change in the 'you save' amount, multiplying $saveprice by the quantity chosen?

        Can any better brains than mine make this happen?

        Thanks again.
        Jonathan Chappell
        Website Designer
        SellerDeck Website Designer
        Actinic to SellerDeck upgrades
        Graphicz Limited - www.graphicz.co.uk

        Comment


          #5
          Jonathan,
          You'd have to write some custom Javascript, triggered by the onchange, which performed additional calculation and then updated the HTML for the "save price" element.

          The idea behind your PHP is fine, however that just controls the static HTML that is uploaded to the server. To effect change on the live, HTML pages online you need to utilise Javascript.
          Fergus Weir - teclan ltd
          Ecommerce Digital Marketing

          SellerDeck Responsive Web Design

          SellerDeck Hosting
          SellerDeck Digital Marketing

          Comment


            #6
            Thanks Fergus - Any volunteers???
            Jonathan Chappell
            Website Designer
            SellerDeck Website Designer
            Actinic to SellerDeck upgrades
            Graphicz Limited - www.graphicz.co.uk

            Comment


              #7
              Dynamically change 'You save' value (RRP, Our price, You save)

              This is posted without warranty or guarantee as a basis for people to develop upon as they wish.
              NB: It will work on the Product Page (Single Product per Page) only.
              Please see Normans following posts:

              1. Implement Fergus' adaptation of the Quantity as a drop down choice as above.

              2. Make a variable at product level RRP (number only).

              3. In the header area of your page layout put the following:

              Code:
              <script type="text/javascript" src="jquery-1.8.3.js"></script>
              	<actinic:block if="%3cactinic%3avariable%20name%3d%22PageType%22%20%2f%3e%20%3d%3d%20%27Product%20Page%27">
              	<script type="text/javascript">//<![CDATA[ 
              $(window).load(function(){
              $('.Qty input').keyup(multiply);
              $('span.Q_<actinic:variable name="ProductID" encoding="perl" selectable="false" /> select').change(multiply);
              function multiply() {
                  var quantity = parseFloat($('.Qty input').val());
              
                  var howmany = $('span.Q_<actinic:variable name="ProductID" encoding="perl" selectable="false" /> select').val();
              
                  $('#total').text('You save £'+(quantity * howmany )); 
              }
              });//]]>  
              
              </script>
              </actinic:block>
              You will have to download a javascript file (jquery-1.8.3.js in this case) and save it in the site folder. You do not need this reference if you are already referencing jquery.

              4. Using the default v12 site go to library, layouts, product and make a copy of the layout 'Image on left text wrapped around. Name the copy 'Image on left text wrapped around QTY box and you save'. Open this layout and replace everything there with this:
              Code:
              <actinic:block if="%3cactinic%3avariable%20name%3d%22IsFilteringEnabled%22%20%2f%3e%20AND%0d%3cactinic%3avariable%20name%3d%22MatchLayouts%22%20%2f%3e%20%3d%3d%20True%20AND%0d%28%3cactinic%3avariable%20name%3d%22PageType%22%20%2f%3e%20%3d%3d%20%22Section%22%29%20AND%0d%3cactinic%3avariable%20name%3d%22IsProductPageGenerated%22%20%2f%3e%20%3d%3d%20True" >
              	<actinic:variable name="FilteredProductLayout" />
              </actinic:block>
              
              <actinic:block if="%28%3cactinic%3avariable%20name%3d%22IsFilteringEnabled%22%20%2f%3e%20AND%0d%3cactinic%3avariable%20name%3d%22MatchLayouts%22%20%2f%3e%20%3d%3d%20False%29%20OR%20%0d%3cactinic%3avariable%20name%3d%22IsFilteringEnabled%22%20%2f%3e%20%20%3d%3d%20False%20OR%0d%28%3cactinic%3avariable%20name%3d%22PageType%22%20%2f%3e%20%3d%3d%20%22Product%20Page%22%29%20OR%0d%3cactinic%3avariable%20name%3d%22IsProductPageGenerated%22%20%2f%3e%20%3d%3d%20False" >
              	
              <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" />
              			<actinic:block if="%28%3cactinic%3avariable%20name%3d%22PageType%22%20%2f%3e%20%3d%3d%20%22Section%22%29" >
              				<input type="hidden" name="PAGEFILENAME" value="<actinic:variable name="SectionPageName" />" />
              			</actinic:block>
              			<actinic:block if="%28%3cactinic%3avariable%20name%3d%22PageType%22%20%2f%3e%20%3d%3d%20%22Product%20Page%22%29" >
              				<input type="hidden" name="PAGEFILENAME" value="<actinic:variable name="ProductPageName" />" />
              			</actinic:block>
              			<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>
              
              		<actinic:block if="%3cactinic%3avariable%20name%3d%22ProductImageFileName%22%20%2f%3e%20%21%3d%20%22%22" >
              			<p class="product-image <actinic:block if="%3cactinic%3avariable%20name%3d%22ProductColumnCount%22%20%2f%3e%20%20%20%3d%3d%20%20%201%20%20OR%20%0d%3cactinic%3avariable%20name%3d%22PageType%22%20%2f%3e%20%3d%3d%20%22Product%20Page%22" >set-left</actinic:block>">
              				<actinic:variable name="ProductImageLayout" />
              			</p>
              		</actinic:block>
              
              		<a name="<actinic:variable name="EncodedProductAnchor" />"></a>			
              
              		<actinic:block if="%3cactinic%3avariable%20name%3d%22PageType%22%20%2f%3e%20%3d%3d%20%22Section%22" >
              			<actinic:block if="%28%3cactinic%3avariable%20name%3d%22ProductListNameLink%22%20%2f%3e%20%3d%3d%201%29" ><a href="<actinic:variable name="ProductPageName" />" onclick="AppendParentSection(this, <actinic:variable name="SectionID" />)">  
              			</actinic:block>
              			<actinic:block if="%28%3cactinic%3avariable%20name%3d%22ProductListNameLink%22%20%2f%3e%20%3d%3d%20%202%29" >
              				<actinic:block if="%3cactinic%3avariable%20name%3d%22ExtendedInformationType%22%20%2f%3e%20%3d%3d%20%22Opens%20in%20a%20Pop%2dUp%20Window%22" >
              					<a href="<actinic:variable name="ExtendedInfoPageEncoded" />" target="ActPopup" onclick="return ShowPopUp('<actinic:variable name="ExtendedInfoPageEncoded" />',<actinic:variable name="ExtInfoWindowWidth" />,<actinic:variable name="ExtInfoWindowHeight" />);">
              				</actinic:block>
              				<actinic:block if="%3cactinic%3avariable%20name%3d%22ExtendedInformationType%22%20%2f%3e%20%3d%3d%20%22Opens%20in%20the%20Same%20Window%22" >
              					<a href="<actinic:variable name="ExtendedInfoPageName" />">
              				</actinic:block>
              			</actinic:block>
              			<actinic:block if="%3cactinic%3avariable%20name%3d%22UseDynamicPrices%22%20%2f%3e%20%3d%3d%20true%20AND%20%3cactinic%3avariable%20name%3d%22ProductComponentCount%22%20%2f%3e%20%3d%3d%200" >
              				<actinic:variable name="ProductJavascriptLayout" />
              			</actinic:block>
              			<actinic:variable formatting="h2" name="ProductName" />
              			<actinic:block if="%28%3cactinic%3avariable%20name%3d%22PageType%22%20%2f%3e%20%3d%3d%20%22Section%22%29%20AND%0d%28%3cactinic%3avariable%20name%3d%22ProductListNameLink%22%20%2f%3e%20%3e%200%29" >
              				</a>
              			</actinic:block>		
              		</actinic:block>
              
              		<actinic:block if="%3cactinic%3avariable%20name%3d%22IsProductReferenceVisible%22%20%2f%3e" >
              			<p>Ref: <actinic:variable name="ProductReference" /></p>
              		</actinic:block>
              
              		<p class="product-text">
              			<actinic:variable name="RealTimeStockDisplay" />
              		</p>
              
              		<actinic:variable name="CartError" />
              		<p class="product-text">
              			<actinic:variable name="ProductDescription" />
              		</p>
              
              		<actinic:block if="%3cactinic%3avariable%20name%3d%22IsCustomerMessageUsed%22%20%2f%3e" >
              			<p class="product-price">
              				<Actinic:PRICE_EXPLANATION PROD_REF="<actinic:variable name="ProductID" />" COMPONENTID=-1><actinic:variable name="RetailCustomerMessage" /></Actinic:PRICE_EXPLANATION>
              			</p>
              		</actinic:block>
              		<actinic:block if="%3cactinic%3avariable%20name%3d%22PriceIsEnabled%22%20%2f%3e" >
              			<p class="product-price">
              			RRP = £<actinic:variable name="RRP" />
              				<Actinic:PRICES PROD_REF="<actinic:variable name="ProductID" />" RETAIL_PRICE_PROMPT="<actinic:variable name="ProductPriceDescription" />">
              				<actinic:variable name="PriceListRetail" />
              				</Actinic:PRICES>
              			</p>
              		</actinic:block>
              		<actinic:block if="%3cactinic%3avariable%20name%3d%22ProductPriceIsEnabled%22%20%2f%3e%20%3d%3d%20False" >
              			<p class="product-price">
              				<Actinic:NOTINB2B><actinic:variable name="ProductPriceNotEnabledMessage" /></Actinic:NOTINB2B>
              			</p>
              		</actinic:block>
              
              		<actinic:block if="%3cactinic%3avariable%20name%3d%22IsQuantityPromptShown%22%20%2f%3e%20AND%20%28%3cactinic%3avariable%20name%3d%22IsOutOfStockShown%22%20%2f%3e%20%3d%3d%20FALSE%29%20AND%20%28%3cactinic%3avariable%20name%3d%22IsCatalogSuspendedShown%22%20%2f%3e%20%3d%3d%20FALSE%29" >  
              			<p class="quantity-box">
              				<actinic:block if="%3cactinic%3avariable%20name%3d%22CartButtonVisibleToAllCustomers%22%20%2f%3e" >
              					<!-- This code is used when the quantity box is visible to all customers -->
              					<span class="actrequired"><actinic:variable name="QuantityPrompt" /></span>
              					&nbsp;
              					<!--<input type="text" name="Q_<actinic:variable name="ProductID" />" value="<actinic:variable name="DefaultQuantity" />" <actinic:block if="%3cactinic%3avariable%20name%3d%22UseDynamicPrices%22%20%2f%3e%20%3d%3d%20TRUE%20AND%20%3cactinic%3avariable%20name%3d%22IsHostMode%22%20%2f%3e%20%3d%3d%20FALSE%20AND%20%3cactinic%3avariable%20name%3d%22IsPreviewMode%22%20%2f%3e%20%3d%3d%20FALSE" >onpaste="QuantityChanged(this, '<actinic:variable name="DynamicPriceCGIURL" />', <actinic:variable name="SectionID" />)" onkeyup="QuantityChanged(this, '<actinic:variable name="DynamicPriceCGIURL" />', <actinic:variable name="SectionID" />)"</actinic:block><actinic:block if="%3cactinic%3avariable%20name%3d%22UseDynamicPrices%22%20%2f%3e%20%3d%3d%20TRUE%20AND%20%3cactinic%3avariable%20name%3d%22IsHostMode%22%20%2f%3e%20%3d%3d%20TRUE%20AND%20%3cactinic%3avariable%20name%3d%22IsPreviewMode%22%20%2f%3e%20%3d%3d%20FALSE" >onpaste="QuantityChanged(this, '<actinic:variable name="DynamicPriceCGIURL" />', <actinic:variable name="SectionID" />, '<actinic:variable name="ShopID" />')" onkeyup="QuantityChanged(this, '<actinic:variable name="DynamicPriceCGIURL" />', <actinic:variable name="SectionID" />, '<actinic:variable name="ShopID" />')"</actinic:block>/>-->
              <span class="Q_<actinic:variable name="ProductID" encoding="perl" selectable="false" />">
              <select name="Q_<actinic:variable name="ProductID" encoding="perl" selectable="false" />"  <actinic:block if="%3cactinic%3avariable%20name%3d%22UseDynamicPrices%22%20%2f%3e%20%3d%3d%20TRUE%20AND%20%3cactinic%3avariable%20name%3d%22IsHostMode%22%20%2f%3e%20%3d%3d%20FALSE%20AND%20%3cactinic%3avariable%20name%3d%22IsPreviewMode%22%20%2f%3e%20%3d%3d%20FALSE" >onchange="QuantityChanged(this, '<actinic:variable name="DynamicPriceCGIURL" />', <actinic:variable name="SectionID" />)"</actinic:block><actinic:block if="%3cactinic%3avariable%20name%3d%22UseDynamicPrices%22%20%2f%3e%20%3d%3d%20TRUE%20AND%20%3cactinic%3avariable%20name%3d%22IsHostMode%22%20%2f%3e%20%3d%3d%20TRUE%20AND%20%3cactinic%3avariable%20name%3d%22IsPreviewMode%22%20%2f%3e%20%3d%3d%20FALSE" >onchange="QuantityChanged(this, '<actinic:variable name="DynamicPriceCGIURL" />', <actinic:variable name="SectionID" />, '<actinic:variable name="ShopID" />')"</actinic:block> />
              <option selected value="1">1</option>
              <option value="2">2</option>
              <option value="3">3</option>
              <option value="4">4</option>
              <option value="5">5</option>
              <option value="6">6</option>
              <option value="7">7</option>
              <option value="8">8</option>
              <option value="9">9</option>
              </select>
              </span>
              
              <actinic:block if="%3cactinic%3avariable%20name%3d%22PriceIsEnabled%22%20%2f%3e" >
              			<actinic:block if="%3cactinic%3avariable%20name%3d%22UseDynamicPrices%22%20%2f%3e%20%3d%3d%20true%20AND%20%3cactinic%3avariable%20name%3d%22ProductComponentCount%22%20%2f%3e%20%3d%3d%200" >
              				<actinic:variable name="ProductJavascriptLayout" />
              			</actinic:block>
              			<actinic:variable name="DynamicPrice" />
              
              		</actinic:block>
              <span class="Qty">
              <input type="hidden" name="Qty" value="
              <actinic:block php="true">
              $rrp = <actinic:variable name="RRP" selectable="false" />;
              $rawprice = <actinic:variable name="ProductPriceRaw" selectable="false" />;
              $rawprice = $rawprice * 1.2; // add in vat if showing VAT inc prices
              // only display is we have an RRP and there's a saving to show
              if ( ($rrp != 0) && ($rrp > $rawprice) )
              {
              $saveprice = round($rrp - $rawprice);
              echo "$saveprice";
              }
              </actinic:block>" />
              </span>
              <br />
              
              <span style="color:red; font-weight:bold;" id="total">You save £
              <actinic:block php="true">
              $rrp = <actinic:variable name="RRP" selectable="false" />;
              $rawprice = <actinic:variable name="ProductPriceRaw" selectable="false" />;
              $rawprice = $rawprice * 1.2; // add in vat if showing VAT inc prices
              // only display is we have an RRP and there's a saving to show
              if ( ($rrp != 0) && ($rrp > $rawprice) )
              {
              $saveprice = round($rrp - $rawprice);
              echo "$saveprice";
              }
              </actinic:block></span>
              				</actinic:block> 
              				<actinic:block if="%3cactinic%3avariable%20name%3d%22EnabledForCustomerGroupID%22%20%2f%3e%20%21%3d%20%22%22" >
              					<actinic:block if="%3cactinic%3avariable%20name%3d%22ProductPriceIsEnabled%22%20%2f%3e" >
              						<!-- This code is used when the quantity box is visible to retail customers, but not all other customer groups -->
              						<Actinic:ShowForPriceSchedule Schedules="<actinic:variable name="EnabledForCustomerGroupID" />">
              						<span class="actrequired"><actinic:variable name="QuantityPrompt" /></span>
              						<input type="text" name="Q_<actinic:variable name="ProductID" />" value="<actinic:variable name="DefaultQuantity" />" <actinic:block if="%3cactinic%3avariable%20name%3d%22UseDynamicPrices%22%20%2f%3e%20%3d%3d%20TRUE%20AND%20%3cactinic%3avariable%20name%3d%22IsHostMode%22%20%2f%3e%20%3d%3d%20FALSE%20AND%20%3cactinic%3avariable%20name%3d%22IsPreviewMode%22%20%2f%3e%20%3d%3d%20FALSE" >onpaste="QuantityChanged(this, '<actinic:variable name="DynamicPriceCGIURL" />', <actinic:variable name="SectionID" />)" onkeyup="QuantityChanged(this, '<actinic:variable name="DynamicPriceCGIURL" />', <actinic:variable name="SectionID" />)"</actinic:block><actinic:block if="%3cactinic%3avariable%20name%3d%22UseDynamicPrices%22%20%2f%3e%20%3d%3d%20TRUE%20AND%20%3cactinic%3avariable%20name%3d%22IsHostMode%22%20%2f%3e%20%3d%3d%20TRUE%20AND%20%3cactinic%3avariable%20name%3d%22IsPreviewMode%22%20%2f%3e%20%3d%3d%20FALSE" >onpaste="QuantityChanged(this, '<actinic:variable name="DynamicPriceCGIURL" />', <actinic:variable name="SectionID" />, '<actinic:variable name="ShopID" />')" onkeyup="QuantityChanged(this, '<actinic:variable name="DynamicPriceCGIURL" />', <actinic:variable name="SectionID" />, '<actinic:variable name="ShopID" />')"</actinic:block>/>
              						</Actinic:ShowForPriceSchedule>
              					</actinic:block>
              					<actinic:block if="%3cactinic%3avariable%20name%3d%22ProductPriceIsEnabled%22%20%2f%3e%20%3d%3d%20FALSE" >		
              						<!-- This code is used when the quantity box needs to hidden from retail customers -->						
              						<actinic:block if="%3cactinic%3avariable%20name%3d%22UseDynamicPrices%22%20%2f%3e%20%3d%3d%20FALSE%20OR%20%3cactinic%3avariable%20name%3d%22IsPreviewMode%22%20%2f%3e%20%3d%3d%20TRUE" >
              						<Actinic:ShowForPriceSchedule Schedules="<actinic:variable name="EnabledForCustomerGroupID" />" HTML="<p><span class='actrequired'><actinic:variable name="QuantityPrompt" /></span>&nbsp;<input type='text' name='Q_<actinic:variable name="ProductID" />' value='<actinic:variable name="DefaultQuantity" />' /></p>"></Actinic:ShowForPriceSchedule>
              						</actinic:block>
              						<actinic:block if="%3cactinic%3avariable%20name%3d%22UseDynamicPrices%22%20%2f%3e%20%3d%3d%20TRUE%20AND%20%3cactinic%3avariable%20name%3d%22IsHostMode%22%20%2f%3e%20%3d%3d%20FALSE%20AND%20%3cactinic%3avariable%20name%3d%22IsPreviewMode%22%20%2f%3e%20%3d%3d%20FALSE" >
              						<Actinic:ShowForPriceSchedule Schedules="<actinic:variable name="EnabledForCustomerGroupID" />" HTML="<p><span class='actrequired'><actinic:variable name="QuantityPrompt" /></span>&nbsp;<input type='text' name='Q_<actinic:variable name="ProductID" />' value='<actinic:variable name="DefaultQuantity" />' onpaste=QuantityChanged(this, '<actinic:variable name="DynamicPriceCGIURL" />', <actinic:variable name="SectionID" />) onkeyup=QuantityChanged(this, '<actinic:variable name="DynamicPriceCGIURL" />', <actinic:variable name="SectionID" />)/></p>"></Actinic:ShowForPriceSchedule>
              						</actinic:block>
              						<actinic:block if="%3cactinic%3avariable%20name%3d%22UseDynamicPrices%22%20%2f%3e%20%3d%3d%20TRUE%20AND%20%3cactinic%3avariable%20name%3d%22IsHostMode%22%20%2f%3e%20%3d%3d%20TRUE%20AND%20%3cactinic%3avariable%20name%3d%22IsPreviewMode%22%20%2f%3e%20%3d%3d%20FALSE" >
              						<Actinic:ShowForPriceSchedule Schedules="<actinic:variable name="EnabledForCustomerGroupID" />" HTML="<p><span class='actrequired'><actinic:variable name="QuantityPrompt" /></span>&nbsp;<input type='text' name='Q_<actinic:variable name="ProductID" />' value='<actinic:variable name="DefaultQuantity" />' onpaste=QuantityChanged(this, '<actinic:variable name="DynamicPriceCGIURL" />', <actinic:variable name="SectionID" />, '<actinic:variable name="ShopID" />') onkeyup=QuantityChanged(this, '<actinic:variable name="DynamicPriceCGIURL" />', <actinic:variable name="SectionID" />, '<actinic:variable name="ShopID" />')/></p>"></Actinic:ShowForPriceSchedule>
              						</actinic:block>
              					</actinic:block>
              				</actinic:block> 
              			</p>
              		</actinic:block>
              		<actinic:block if="%3cactinic%3avariable%20name%3d%22IsQuantityPromptHidden%22%20%2f%3e" >
              			<p class="quantity-box">
              				<input type="hidden" name="Q_<actinic:variable name="ProductID" />"  value="<actinic:variable name="DefaultQuantity" />" />
              			</p>
              		</actinic:block>
              		<!-- End of code for quantity box -->
              
              		<actinic:block if="%3cactinic%3avariable%20name%3d%22IsAddToCartButtonShown%22%20%2f%3e%20AND%20%0d%28%3cactinic%3avariable%20name%3d%22NumberAttributesInPushButtonGrid%22%20%2f%3e%20%3d%3d%200%29" >
              			<p class="cart-button-placement">
              				<actinic:variable name="AddToCartButton" />
              			</p>
              		</actinic:block>
              		<actinic:block if="%3cactinic%3avariable%20name%3d%22IsOutOfStockShown%22%20%2f%3e" >
              			<p class="cart-button-placement">
              				<strong><span class="actrequired"><actinic:variable name="OutOfStock" /></span></strong>
              			</p>
              		</actinic:block>
              		<actinic:block if="%3cactinic%3avariable%20name%3d%22IsCatalogSuspendedShown%22%20%2f%3e" >
              			<p class="cart-button-placement">
              				<strong><span class="actrequired"><actinic:variable name="CatalogSuspended" /></span></strong>
              			</p>
              		</actinic:block>
              
                
              
              
              
              
              <!-- ends -->
              		<actinic:variable name="FeefoProductLogo" />
              		<div id="idVars<actinic:variable name="ProductID" />">
              		<actinic:variable name="AttributeList" /> 
              		<actinic:variable name="ComponentList" />
              		</div>
              		<p class="product-text">
              			<actinic:variable name="ProductLinks" />
              		</p>
              		
              		<actinic:block if="%3cactinic%3avariable%20name%3d%22FileURLNotEmpty%22%20%2f%3e" >
              			<p class="product-text"><a href="<actinic:variable name="ProductLinkInfo" />">
              				<actinic:variable encoding="actinic" name="ProductLinkText" /> 
              			</a></p>
              		</actinic:block>
              
              		<actinic:block if="%3cactinic%3avariable%20name%3d%22DiscountDescriptionIsShownForProducts%22%20%2f%3e" >      
              			<p class="product-text"><actinic:variable name="DiscountList" value="Standard Discount List" /></p>
              		</actinic:block>
              
              		<actinic:block if="%3cactinic%3avariable%20name%3d%22IsOtherInfoPromptShown%22%20%2f%3e" >
              			<p class="product-prompt"><span class="actrequired"><actinic:variable encoding="actinic" name="OtherInfoPrompt" /></span></p>
              			<input class="input-border" type="text" name="O_<actinic:variable name="ProductID" />" maxlength="1000" value="" />
              		</actinic:block>
              
              		<actinic:block if="%3cactinic%3avariable%20name%3d%22IsDatePromptShown%22%20%2f%3e" >
              			<p class="product-prompt"><span class="actrequired"><actinic:variable name="DatePrompt" /></span></p>
              			<actinic:variable name="DayList" /><actinic:variable name="MonthList" /><actinic:variable name="YearList" />
              		</actinic:block>
              
              		<actinic:variable name="ProductAlsoBoughtList" />
              		<actinic:variable name="ProductRelatedProductsList" />
              
              		<!-- End of Product Text -->
              
              	<div class="set-below-right">
              		<actinic:variable name="FeefoProductFeedback" />
              	</div>
              
              	<!-- End of Product Details -->
              
              	<actinic:block if="%3cactinic%3avariable%20name%3d%22IsProductFormUsed%22%20%2f%3e" >
              		</form>
              	</actinic:block>
              	</actinic:block>
              It will be easier to see what is happening with this layout when you look at it in Sellerdeck.

              There is a live version at: http://www.graphicz.gb.com/generic/a...g-1.html#SID=1

              Thank you.
              Last edited by graphicz; 25-Mar-2013, 10:50 AM. Reason: Clarify single product per page use
              Jonathan Chappell
              Website Designer
              SellerDeck Website Designer
              Actinic to SellerDeck upgrades
              Graphicz Limited - www.graphicz.co.uk

              Comment


                #8
                If you're always using this on a SPP layout then things may seem fine but anyone trying to use this on multi products per page will have problems.

                1) Putting code into the Overall Layouts that includes a ProductID variable will not work on pages that never have products (you may get variable used out of context errors). And of course only works if it's a single product per page.

                2) Not sure if $('.Qty input').keyup(multiply); does anything since it refers to a hidden field which will never have focus and thus never have keyboard input.

                3) The code $('#total').text('You save £'+(quantity * howmany )); will only work if there's only 1 product on the page (you can only have one instance of a unique ID).

                And some code to run through all drop-downs on page load and do the calculation may be needed. If you reload a page (only tried Firefox) when a quantity other than 1 has already been selected, then the displayed saving is wrong. Note that SellerDeck's own dynamic pricing doesn't seem to work properly in this case either.
                Norman - www.drillpine.biz
                Edinburgh, U K / Bitez, Turkey

                Comment


                  #9
                  Here's how I'd go about this with much less code needed. And it will work on multiple products per page too. Also nothing is displayed if the RRP is 0 or is less than the retail price.

                  Make a variable at product level RRP (number only).

                  Put a copy of jquery-1.8.3.min.js into your Site folder. If your site already uses jQuery it won't matter as we only load the ours if it's not already present.

                  At the bottom of layout Standard JavaScript Header Functions add:
                  Code:
                  <script type="text/javascript">
                  	// load jQuery if not already present
                  	if ( typeof(jQuery) == 'undefined' ) document.write('<script type="text/javascript" src="jquery-1.8.3.min.js"></sc' + 'ript>');
                  </script>
                  <script type="text/javascript">
                  	function multiply() {								// calculate rrp based amount saved times selected quantity
                  		var pid = this.name.replace('Q_', '');		// extract the product ID from field named Q_<productID>
                  		var rrp = $(this).attr('rrp');				// rrp is stored here
                  		var ppraw = $(this).attr('ppraw') * 1.2;	// product price raw (if using non VAT Inc prices change 1.2 to 1)
                  		var qty = $(this).val();						// the quantity currently selected
                  		$('#totalsave_' + pid).html((qty > 0) && (rrp > ppraw) ? 'You save £' + (qty * (rrp - ppraw)).toFixed(2) : '');	// display total if valid 
                  	}	
                  
                  	$(document).ready(function(){						
                  		$('input.qtyselect').keyup(multiply).keyup();	// normal Quantity fields: attach the multiply function and then execute it
                  		$('select.qtyselect').change(multiply).change();// dropdown quantity fields: attach the multiply function and then execute it
                  	});
                  </script>
                  Replace the Quantity entry field in your Product Layout(s) with:
                  Code:
                  <select class="qtyselect" ppraw="<actinic:variable name="ProductPriceRaw" />" rrp="<actinic:variable name="RRP" />" name="Q_<actinic:variable name="ProductID" encoding="perl" selectable="false" />" <actinic:block if="%3cactinic%3avariable%20name%3d%22UseDynamicPrices%22%20%2f%3e%20%3d%3d%20TRUE%20AND%20%3cactinic%3avariable%20name%3d%22IsHostMode%22%20%2f%3e%20%3d%3d%20FALSE%20AND%20%3cactinic%3avariable%20name%3d%22IsPreviewMode%22%20%2f%3e%20%3d%3d%20FALSE" >onchange="QuantityChanged(this, '<actinic:variable name="DynamicPriceCGIURL" />', <actinic:variable name="SectionID" />)"</actinic:block><actinic:block if="%3cactinic%3avariable%20name%3d%22UseDynamicPrices%22%20%2f%3e%20%3d%3d%20TRUE%20AND%20%3cactinic%3avariable%20name%3d%22IsHostMode%22%20%2f%3e%20%3d%3d%20TRUE%20AND%20%3cactinic%3avariable%20name%3d%22IsPreviewMode%22%20%2f%3e%20%3d%3d%20FALSE" >onchange="QuantityChanged(this, '<actinic:variable name="DynamicPriceCGIURL" />', <actinic:variable name="SectionID" />, '<actinic:variable name="ShopID" />')"</actinic:block> />
                  	<option selected value="1">1</option>
                  	<option value="2">2</option>
                  	<option value="3">3</option>
                  	<option value="4">4</option>
                  	<option value="5">5</option>
                  	<option value="6">6</option>
                  	<option value="7">7</option>
                  	<option value="8">8</option>
                  	<option value="9">9</option>
                  </select>
                  
                  <actinic:block if="%3cactinic%3avariable%20name%3d%22RRP%22%20%2f%3e%20%3e%20%28%3cactinic%3avariable%20name%3d%22ProductPriceRaw%22%20%2f%3e%20%2a%201%2e2%29" >
                  	RRP: <actinic:block php="true">printf("£%01.2f", <actinic:variable name="RRP" selectable="false" />);</actinic:block> <span style="color:red; font-weight:bold;" id="totalsave_<actinic:variable name="ProductID" />"></span>
                  </actinic:block>
                  Note that the big lumps of PHP are gone as we're already doing such a calculation in JavaScript when the document is ready. And also some unnecessary SPAN tags.

                  Note that there's a 1.2 multiplier in the JavaScript and the BlockIf around the RRP display. Change this if VAT changes or set both to 1 if displaying VAT exclusive prices.
                  Norman - www.drillpine.biz
                  Edinburgh, U K / Bitez, Turkey

                  Comment


                    #10
                    The above tweak should work on normal Quantity entry fields too. In such cases, add the following to the quantity input tags:
                    Code:
                     class="qtyselect" ppraw="<actinic:variable name="ProductPriceRaw" />" rrp="<actinic:variable name="RRP" />"
                    And add this to the Product Layout(s) to display the RRP and saving:
                    Code:
                    <actinic:block if="%3cactinic%3avariable%20name%3d%22RRP%22%20%2f%3e%20%3e%20%28%3cactinic%3avariable%20name%3d%22ProductPriceRaw%22%20%2f%3e%20%2a%201%2e2%29" >
                    	RRP: <actinic:block php="true">printf("£%01.2f", <actinic:variable name="RRP" selectable="false" />);</actinic:block> <span style="color:red; font-weight:bold;" id="totalsave_<actinic:variable name="ProductID" />"></span>
                    </actinic:block>
                    And, of course, put the same stuff into Standard JavaScript Header Functions as in the post above.
                    Norman - www.drillpine.biz
                    Edinburgh, U K / Bitez, Turkey

                    Comment


                      #11
                      Thank you Norman

                      Here it is working

                      http://www.graphicz.gb.com/yousave/a...g-1.html#SID=1

                      I had to add single quotes to a condition to remove a warning
                      Code:
                      <actinic:block if="%3cactinic%3avariable%20name%3d%22RRP%22%20%2f%3e%20%3e%20%28%27%3cactinic%3avariable%20name%3d%22ProductPriceRaw%22%20%2f%3e%20%2a%201%2e2%27%29" >
                      	RRP: <actinic:block php="true">printf("£%01.2f", <actinic:variable name="RRP" selectable="false" />);</actinic:block> <span style="color:red; font-weight:bold;" id="totalsave_<actinic:variable name="ProductID" />"></span>
                      </actinic:block>
                      Jonathan Chappell
                      Website Designer
                      SellerDeck Website Designer
                      Actinic to SellerDeck upgrades
                      Graphicz Limited - www.graphicz.co.uk

                      Comment


                        #12
                        Hi, Jonathan

                        Not sure why you got a warning. AFAIK ProdutPriceRaw is always numeric. When did the warning appear?
                        Norman - www.drillpine.biz
                        Edinburgh, U K / Bitez, Turkey

                        Comment


                          #13
                          Strangely when implementing it in another site I got the Faulty Condition warning with the single quotes and had to remove them. Maybe I had some syntax wrong somewhere in the first attempt.

                          Anyway Norman, it is a brilliant solution, thank you so much.
                          Jonathan Chappell
                          Website Designer
                          SellerDeck Website Designer
                          Actinic to SellerDeck upgrades
                          Graphicz Limited - www.graphicz.co.uk

                          Comment


                            #14
                            Changing RRP according to hidden choice products

                            The above works very well.
                            Slight problem where the choices are hidden products with their own prices and RRP.
                            The price changes dynamically if the choice product is more expensive
                            but the RRP stays as is for the base product.
                            I am not optimistic but is there a way to display the RRP of the hidden product when that choice is made in the drop down?

                            Try here: http://www.graphicz.gb.com/mtyex/aca...005.html#SID=7 chose silver or gold from the colour drop down.

                            Thank you.
                            Jonathan Chappell
                            Website Designer
                            SellerDeck Website Designer
                            Actinic to SellerDeck upgrades
                            Graphicz Limited - www.graphicz.co.uk

                            Comment

                            Working...
                            X