get Selected Attribute price

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mnkyhead
    Mini Mivite

    • Jan 2010
    • 21

    #1

    get Selected Attribute price

    There must be away to get the price from a selected attribute for a product with out using a module(well I have toolkit, so I could use that if I knew how).

    I want to replace the price on the product page with that of the selected attribute option. I have done some searching on the forums, but didn't come up with any answers.

    any thoughts?

    Thanks
    Russ
  • Rick Wilson
    Uber Mivite











    • Aug 2007
    • 10119

    #2
    Re: get Selected Attribute price

    Russ,

    Let me make sure I understand what you're asking.

    Let's say product A costs $10 but when you choose Attribute A that adds $5 to the price? You'd like the price on the page to dynamically change from $10 to $15 if someone chooses that attribute?
    Thanks,

    Rick Wilson
    CEO
    Miva, Inc.
    [email protected]
    https://www.miva.com

    Comment

    • mnkyhead
      Mini Mivite

      • Jan 2010
      • 21

      #3
      Re: get Selected Attribute price

      Yes that is what I am trying to do.

      Comment

      • Rick Wilson
        Uber Mivite











        • Aug 2007
        • 10119

        #4
        Re: get Selected Attribute price

        This is built into our next release (Core 18) which is in Public Beta now. It'll be pushed out to everyone in the coming weeks.
        Thanks,

        Rick Wilson
        CEO
        Miva, Inc.
        [email protected]
        https://www.miva.com

        Comment

        • mnkyhead
          Mini Mivite

          • Jan 2010
          • 21

          #5
          Re: get Selected Attribute price

          OK here is my solution in the mean time. This only works for the select option for attributes.
          I am using Javascript to capture the label parameter of the selected item into which I placed the options price.
          so I updated the select tag in the Product Attribute Template, adding the onchange param like this

          Code:
          <select name="Product_Attributes[&mvt:attribute:index;]:value"  onchange="getCombo1(this)">
          Then I updated the option tags of the select adding the label parameter which holds the price.
          Code:
          <option value="&mvte:option:code;" label="&mvte:option:formatted_price;" selected>&mvte:option:prompt;</option>
                  <mvt:else>
                  <option value="&mvte:option:code;" label="&mvte:option:formatted_price;">&mvte:option:prompt;</option>
                  </mvt:if>
          On the Product Display Layout I added a if/else statement which checks to see if the product has a price. In the else statement I added a text input to receive the price of the attribute. For my store products only have attribute prices. The one issue I haven't worked out here is the default price for the product.
          Code:
          <mvt:if expr="l.settings:product:price GT 0">
          <h5>Price:&nbsp;</h5> &mvt:product:formatted_price;
          <mvt:else>
          <h5>Price:&nbsp;</h5><input id="attPrice" type="text" style="background:none; border-style:none;" readonly="readonly" value="$10.00">
          </mvt:if>
          On the main product page I added some javascript to the head tag. This function is called when the select menu of the attribute is changed and a reference to the select is passed to the function. It pulls the label value of the selected item, and writes it into the input on the product layout.
          Code:
          <script language="javascript">
          function getCombo1(sel) { 
              document.getElementById("attPrice").value = sel.options[sel.selectedIndex].label; 
          }
          </script>
          So My products only have one attribute, so it makes it pretty simple.
          Last edited by mnkyhead; 02-11-10, 01:44 PM.

          Comment

          • mnkyhead
            Mini Mivite

            • Jan 2010
            • 21

            #6
            Re: get Selected Attribute price

            Oh see it in action here

            Comment

            Working...
            X