Announcement

Collapse
No announcement yet.

Show sale price for inventory variant

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

    Show sale price for inventory variant

    We are moving our current store to the latest Miva and switching all products to use inventory variants.

    Today, if we have a product which has 3 colors, there are 3 actual products in the cart.

    We are moving to using Inventory Variants so there is only 1 product, and the color is a variant. We are tracking inventory and pricing at the inventory variant level.

    Today, the way we show sales, clearance, etc....is I have a custom field for each product. If say a product is normally $20 but it's on sale for $10....I change the price of the product to $10 and in the custom sale field I put in $20. I then run Miva conditionals to test for this and instead of just writing out the price...I write out the price with Sale Price: in front and the regular price below and crossed out.

    However, with switching to Attribute Machine.....all this is done in the Javascript.....not on page load. Does anyway know....is it possible to do something like this....to have attribute machine swap out not only the price but any custom fields?

    I know this still works if everything is done at the main product level....but we need to have the ability to put certain colors on sale, clearance.

    How are people handling "showing" that a variant is on sale?

    -Kevin
    Web Design and Development, Internet Marketing
    Lancer Media, Inc.

    #2
    Re: Show sale price for inventory variant

    Yes it is possible, but requires some custom JavaScript code and an AJAX call to get the data.

    We do it here: http://www.foambymail.com/MFM-_3.html

    Basically you still store the MSRP in a custom field but the variant custom fields are not on the page when it loads. So you need to tie into Attribute Machine and when a variant is changed, make a ajax call to get the custom field value of the variant selected and update the page.

    In this case I believe we are using toolbelt because we are executing a native Miva function using the MvDo command.

    Let me know if this is what you're after and I can post some code snippets.
    Brennan Heyde
    VP Product
    Miva, Inc.
    [email protected]
    https://www.miva.com

    Comment


      #3
      Re: Show sale price for inventory variant

      Brennan,

      Yeah this is exactly what we want to do.

      When we display the regular price, we don't display anything special....just Price: $20.00

      For our products I have 3 custom fields setup:

      1) Sale price
      2) Clearance price
      3) Introductory price

      Using Miva conditionals I check on page load if these have values in them (obviously only 1 at any given time will have a value).

      So we'd like to do that today with using Attribute Machine and the inventory variants.

      You mentioned toolbelt. We don't have that, but we are using toolkit.

      Any code snippets would be awesome. Thanks!

      -Kevin
      Web Design and Development, Internet Marketing
      Lancer Media, Inc.

      Comment


        #4
        Re: Show sale price for inventory variant

        @Kevin - Here is an example of how you should be able to accomplish what you are looking for.

        1) Purchase and install the Tool Belt module.

        2) Create a page with the code of "APVCF", you can name it whatever...we usually call it "AJAX Product Variant Custom Fields", and paste this code into the page:

        Code:
        <mvt:comment>Creates the functions and variables needed to access variant product information and custom product fields.</mvt:comment>
        <mvt:item name="ry_toolbelt" param="do|g.module_library_db|g.result1|Runtime_Product_Load_Code( g.Product_Code, l.all_settings:master_product )" />
        <mvt:item name="ry_toolbelt" param="do|g.module_library_db|g.result2|ProductList_Load_Variant( l.all_settings:master_product:id, g.Variant_ID, l.all_settings:part_products )" />
        <mvt:item name="ry_toolbelt" param="custom_products|l.all_settings:customfields|l.all_settings:part_products[1]:id" />
        
        <mvt:comment>Pulls the "salePrice" custom product field value from variant product, encodes the value and then formats the value to jQuery JSON format.</mvt:comment>
        <mvt:item name="ry_toolbelt" param="do|g.module_json|g.temp|JSON_Encode( l.all_settings:customfields:value:salePrice )" />
        <mvt:item name="ry_toolbelt" param="assign|l.all_settings:customfields:value_encoded:salePrice|glosub( g.temp, '\x', '\u00' )" />
        
        <mvt:comment>Pulls the "clearancePrice" custom product field value from variant product, encodes the value and then formats the value to jQuery JSON format.</mvt:comment>
        <mvt:item name="ry_toolbelt" param="do|g.module_json|g.temp|JSON_Encode( l.all_settings:customfields:value:clearancePrice )" />
        <mvt:item name="ry_toolbelt" param="assign|l.all_settings:customfields:value_encoded:clearancePrice|glosub( g.temp, '\x', '\u00' )" />
        
        <mvt:comment>Pulls the "introPrice" custom product field value from variant product, encodes the value and then formats the value to jQuery JSON format.</mvt:comment>
        <mvt:item name="ry_toolbelt" param="do|g.module_json|g.temp|JSON_Encode( l.all_settings:customfields:value:introPrice )" />
        <mvt:item name="ry_toolbelt" param="assign|l.all_settings:customfields:value_encoded:introPrice|glosub( g.temp, '\x', '\u00' )" />
        
        <mvt:comment>Return a JSON array of the custom product fields.</mvt:comment>
        <mvt:item name="ry_toolbelt" param="currencyformat|l.all_settings:product_variant:msrp|l.all_settings:part_products[1]:price * 1.1" />
        
        {"salePrice": "&mvt:customfields:value_encoded:salePrice;","clearancePrice": "&mvt:customfields:value_encoded:clearancePrice;","introPrice": "&mvt:customfields:value_encoded:introPrice;"}
        3) You'll need to edit your PROD page to call the AJAX function and then perform whatever actions you would like to happen (this sample script assumes you are using jQuery):

        Code:
        <script type="text/javascript">
            MivaEvents.SubscribeToEvent('variant_changed', function(product_data) {
                <mvt:if expr="g.secure">
                    $.getJSON('&mvt:global:secure_sessionurl;Screen=APVCF&Product_Code=' + encodeURIComponent(product_data.product_code) + '&Variant_ID=' + encodeURIComponent(product_data.variant_id),
                <mvt:else>
                    $.getJSON('&mvt:global:sessionurl;Screen=APVCF&Product_Code=' + encodeURIComponent(product_data.product_code) + '&Variant_ID=' + encodeURIComponent(product_data.variant_id),
                </mvt:if>
                function(data) {
                    /* Checks "salePrice" Custom Product Field - Toggles Message */
                    if (data.salePrice.length != 0) {
                        $('#price-element').text('$' + data.salePrice);
                    };
                });
            });
        </script>
        Matt Zimmermann

        Miva Web Developer
        Alchemy Web Development
        https://www.alchemywebdev.com
        Site Development - Maintenance - Consultation

        Miva Certified Developer
        Miva Professional Developer

        https://www.dev4web.net | Twitter

        Comment


          #5
          Re: Show sale price for inventory variant

          Matt,

          Thanks for the code. Couple of quick questions:

          1) Can you have both toolkit and toolbelt installed in the store?
          2) Is there a reason this was done in toolbelt? Is this not possible with toolkit?

          Thanks again.....I'm going to get the client to buy the module and I'll test this out.

          -Kevin
          Web Design and Development, Internet Marketing
          Lancer Media, Inc.

          Comment


            #6
            Re: Show sale price for inventory variant

            @Kevin - You're welcome. Yes, you can have both Tool Kit and Tool Belt installed in a store. Unfortunately, Tool Belt is needed becuse it supports the "do" function which is not in Tool Kit.
            Matt Zimmermann

            Miva Web Developer
            Alchemy Web Development
            https://www.alchemywebdev.com
            Site Development - Maintenance - Consultation

            Miva Certified Developer
            Miva Professional Developer

            https://www.dev4web.net | Twitter

            Comment


              #7
              Re: Show sale price for inventory variant

              Originally posted by Matt Zimmermann View Post
              @Kevin - You're welcome. Yes, you can have both Tool Kit and Tool Belt installed in a store. Unfortunately, Tool Belt is needed becuse it supports the "do" function which is not in Tool Kit.
              Awesome thanks Matt. I was more curious to know since to date I've only dealt with toolkit.

              I'll get this ordered and try and let you know.

              -Kevin
              Web Design and Development, Internet Marketing
              Lancer Media, Inc.

              Comment


                #8
                Re: Show sale price for inventory variant

                Matt,

                Thanks again for the code. I have been able to get it working.

                I have run into some issues mainly because, of the 4 colors for this products, generally 2 of them are not on sale.....so it wouldn't show a sale price and a regular price. The site you gave as an example ALWAYS has a sale and regular price.

                So I've had to play around with the code a bit to get things to work.....taking into account the possible scenarios:

                - only 2 of the products are on clearance, the other 2 regular price
                - the client might want to put the normal 2 on sale....so 2 on sale, 2 on clearance

                The main issue is whether the pricing is controlled at the inventory level, or the main product level. Most of our products in the store are all controlled at the main product level (there is no color specific pricing). So my original code to show the sale/regular pricing still works....and it works on the CTGY template as well.....since it seems the CTGY template is looking at the main product, not the inventory variants.

                -Kevin
                Web Design and Development, Internet Marketing
                Lancer Media, Inc.

                Comment


                  #9
                  Re: Show sale price for inventory variant

                  Kevin,

                  Here's another approach to inventory variants and the ability to indicate a certain option is on sale based on a custom product field in the variant record. It also gives you the ability to add bulk quantities for one or more of the options from the product page with a single add to basket button click. It is using the Emporium Plus Tool Kit for these features. http://www.emporiumplus.com/SAMPLE5.html
                  Bill Weiland - Emporium Plus http://www.emporiumplus.com/store.mvc
                  Online Documentation http://www.emporiumplus.com/tk3/v3/doc.htm
                  Question http://www.emporiumplus.com/mivamodu...vc?Screen=SPTS
                  Facebook http://www.facebook.com/EmporiumPlus
                  Twitter http://twitter.com/emporiumplus

                  Comment


                    #10
                    Re: Show sale price for inventory variant

                    Thanks Bill....that's interesting. Not sure the client wants that layout on this site....he wants the dropdowns and dynamic price changes.

                    BUT, this is very intriguing for a wholesale site he wants to do.

                    -Kevin
                    Web Design and Development, Internet Marketing
                    Lancer Media, Inc.

                    Comment


                      #11
                      I'd like to revisit this topic and ask if anyone knows if there is a new way of putting variants on sale without custom fields, etc. I also need to the variant sale price to appear in the dropdown. It's been a long time since 2012.
                      Jason Lindsey
                      Dreamchaser Design
                      www.dreamchaserdesign.com
                      "You Dream. We Design."

                      Comment


                        #12
                        Hi Jason -

                        This functionality is all out of the box now. You can assign the variant to the a price group and attribute machine will show the correct sale price as variants are selected.
                        Brennan Heyde
                        VP Product
                        Miva, Inc.
                        [email protected]
                        https://www.miva.com

                        Comment


                          #13
                          Great, I'll give it shot, thanks!
                          Jason Lindsey
                          Dreamchaser Design
                          www.dreamchaserdesign.com
                          "You Dream. We Design."

                          Comment

                          Working...
                          X