Announcement

Collapse
No announcement yet.

Auto add quantity depending of result of calculation

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

    Auto add quantity depending of result of calculation

    Ill tell you my problem,

    We sell flooring online and we want the customer to be able to work out how many for tiles they need..

    Eg the formular for 500mm x 500mm tile is as simple as
    (Square M2 * 4 = amount needed) (i've worked out how to do this in php already but not with actinic

    With this "amount needed" i want it to automatically put the result of the calculation in the quantity box.

    Can anyone help?

    James
    www.polymax.co.uk/acatalog/ number 1 for for o-rings, rubber seals, rubber cords. In Viton NBR and silicone.
    Cuddle And Carry, Baby Slings Wraps Ringslings Pouches and Carriers
    http://www.oringen.eu/ O-Ringen Rubber Koord Uitegdreven Profielen in Nitrile (NBR) Viton.

    #2
    Hi James,
    We have provided a similar solution for an existing Actinic customer recently. Get in touch or PM me if you want some more information on how our solution works as it sounds as if it is an almost identical issue that you require solving.
    Fergus Weir - teclan ltd
    Ecommerce Digital Marketing

    SellerDeck Responsive Web Design

    SellerDeck Hosting
    SellerDeck Digital Marketing

    Comment


      #3
      The quantity is held in a field like:
      Code:
      <input type="text" name="Q_<actinic:variable Name="ProductID"/>" size="4" value="<Actinic:Variable Name="DefaultQuantity"/>" class="form_input_general" />
      So make a custom product layout containing
      Code:
      <script type="text/javascript">
      function calculate(pid){
        document.getElementById('Q_' + pid).value = 4 * document.getElementById('XXX_' + pid).value * document.getElementById('YYY_' + pid).value;
      }
      </script>
      Width in meters: <input type="text" id="XXX_<actinic:variable Name="ProductID"/>" size="4" value="0" class="form_input_general" onchange="calculate('<actinic:variable Name="ProductID" encoding="perl" selectable="false" />')" />
      Depth in meters: <input type="text" id="YYY_<actinic:variable Name="ProductID"/>" size="4" value="0" class="form_input_general" onchange="calculate('<actinic:variable Name="ProductID" encoding="perl" selectable="false" />')" />
      Code is untested. Preview in Firefox and use its Tools / Error Console to debug.
      Norman - www.drillpine.biz
      Edinburgh, U K / Bitez, Turkey

      Comment


        #4
        There you go James - Norman has excellent solution for you.

        Our solution was similar with just the original quantity field being hidden and a dynamic display of adjusted price showing on page.
        Fergus Weir - teclan ltd
        Ecommerce Digital Marketing

        SellerDeck Responsive Web Design

        SellerDeck Hosting
        SellerDeck Digital Marketing

        Comment


          #5
          Adding in a basic cost calulation we get.

          The quantity is held in a field like:
          Code:
          <input type="text" name="Q_<actinic:variable Name="ProductID"/>" size="4" value="<Actinic:Variable Name="DefaultQuantity"/>" class="form_input_general" />
          So make a custom product layout containing
          Code:
          <script type="text/javascript">
          function calculate(pid){
            var numtiles = 4 * document.getElementById('XXX_' + pid).value * document.getElementById('YYY_' + pid).value;
            document.getElementById('Q_' + pid).value = numtiles;
            var tilecost = numtiles * 1.175 * <actinic:variable name="ProductPriceRaw" encoding="perl" selectable="false" />;
            document.getElementById('CCC_' + pid).innerHTML = tilecost.toFixed(2);
          }
          </script>
          Width in meters: <input type="text" id="XXX_<actinic:variable Name="ProductID"/>" size="4" value="0" class="form_input_general" onchange="calculate('<actinic:variable Name="ProductID" encoding="perl" selectable="false" />')" />
          Depth in meters: <input type="text" id="YYY_<actinic:variable Name="ProductID"/>" size="4" value="0" class="form_input_general" onchange="calculate('<actinic:variable Name="ProductID" encoding="perl" selectable="false" />')" />
          Total cost: £<span id="CCC_<actinic:variable Name="ProductID"/>" >---</span>
          Code is untested. Preview in Firefox and use its Tools / Error Console to debug.
          Norman - www.drillpine.biz
          Edinburgh, U K / Bitez, Turkey

          Comment


            #6
            And you could create a user Variable NumTilesPerSqM that you use instead of the hard-coded 4 above.
            Norman - www.drillpine.biz
            Edinburgh, U K / Bitez, Turkey

            Comment

            Working...
            X