Announcement

Collapse
No announcement yet.

Automatically Update Product Price Before User Checks Out

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

    Automatically Update Product Price Before User Checks Out

    Hey everyone,
    We discovered what we think is a pretty big issue with the standard functionality of our store. If we update a price of a product, this price is not reflected in a customers shopping cart if they already had it in their basket. With today's manufacturing issues we are constantly adjusting pricing. I opened a ticket for this issue and I was told that this is the way it works and I can just dump all the carts if I make a price change. This 100% does not work for us as we sell a ton of little parts to hobbyists. I will admit that we do have a VERY long timeout on carts, but this is what our customers requested. I am hoping someone at Miva sees the issue with this and can add this to a future enhancement.

    A temporary solution would be the ability to recalculate carts prices with a scheduled task, but that does not seem to be an option either. If this was an option, we could run the task whenever we update a product price.

    I am at the point where I am about to write an update query directly to the BasketItems table in the database when we have to change a price. This is obviously not ideal, but better than using a delete query to remove the individual items from baskets.

    Does anyone have any other suggestions?

    Thank you,
    --Scott
    Last edited by scottd21; 04-07-22, 12:21 PM.

    #2
    You could also see it from the customer's point of view and magically their items in the cart are changing prices. Basket items are their own table, just like order items. So they're not linked once in the cart in terms of a price update.

    If you wanted to do what you ask, it's totally possible and use all built in API calls.
    1. For each basket group item you need to run this
    https://docs.miva.com/api-functions/...duct_load_code
    and see if the price is dfifferent.
    If it's different then you use this or similar function. https://docs.miva.com/api-functions/...update_pricing I think the param it needs is the entire basket line item. So copy the current line item to a var/struct, change it's price, then run the API. Then throw a javascript alert to tell the customer you're changing their price and location.replace with the basket url. When the page loads it will have the corrected product price.
    Colin Puttick
    Miva Web Developer @ Glendale Designs

    Comment


      #3
      Originally posted by dreamingdigital View Post
      You could also see it from the customer's point of view and magically their items in the cart are changing prices. Basket items are their own table, just like order items. So they're not linked once in the cart in terms of a price update.

      If you wanted to do what you ask, it's totally possible and use all built in API calls.
      1. For each basket group item you need to run this
      https://docs.miva.com/api-functions/...duct_load_code
      and see if the price is dfifferent.
      If it's different then you use this or similar function. https://docs.miva.com/api-functions/...update_pricing I think the param it needs is the entire basket line item. So copy the current line item to a var/struct, change it's price, then run the API. Then throw a javascript alert to tell the customer you're changing their price and location.replace with the basket url. When the page loads it will have the corrected product price.
      Thanks for the info Colin, I appreciate that. I am just confused why this functionality would not be in the system already to alert and update the price in the customers basket. I have had this happen as a customer numerous times on other websites that I use where a price of a limited item gets adjusted on the fly. As a customer, I don't expect to lock a price by adding something to my cart and keeping the cart alive for a while. Early on in our Miva implementation we also had to get some custom development done to ensure that users could not check out with items that were out of stock in their cart. We ended up overselling a bunch of products until this development was done. We also cannot tie up inventory when someone adds something to their cart as that would not be fair to others trying to get some of these limited run pieces.

      Thank you again for that code info above. I will take a look and attempt to use that on our BASK page and see if I can get it updating automatically.

      --Scott

      Comment


        #4
        Here is some example code that just identifies that a product in the basket has a different price. I've seen this request enough to justify us looking to adding this in as a feature/setting in Miva.

        Code:
        <mvt:foreach iterator="group" array="basket:groups">
        
        <mvt:do name="l.return" file="g.Module_Library_DB" value="Runtime_Product_Load_Code( l.settings:group:code, l.settings:product )" />
        
        <mvt:if expr="l.settings:group:price NE l.settings:product:price">
        Item: &mvte:group:code; Price has changed!
        </mvt:if>
        
        </mvt:foreach>
        This is simply outputting text that the item price has changed. If you wanted to automatically update the price there is a new function we released in 10.03 that makes this much easier:

        Code:
        function Runtime_BasketGroup_Update( group_id, data, callback, delegator )
        {
        return AJAX_Call_JSON( callback, 'runtime', 'Runtime_BasketItem_Update',
        {
        Group_ID: group_id,
        Quantity: data.quantity,
        Subscription_Term_ID: data.subterm_id,
        Attributes: data.attributes
        }, delegator );
        }
        https://docs.miva.com/miva10/referen...mejs-reference
        Brennan Heyde
        VP Product
        Miva, Inc.
        [email protected]
        https://www.miva.com

        Comment


          #5
          Thanks Brennan,
          I will dig into this a bit more. I thought I found a place where the code was updating the price, but it turned out to not be doing that properly in the increment and decrement code.
          Thanks,
          --Scott
          Last edited by scottd21; 04-08-22, 07:41 AM.

          Comment


            #6
            Originally posted by Brennan View Post
            Here is some example code that just identifies that a product in the basket has a different price. I've seen this request enough to justify us looking to adding this in as a feature/setting in Miva.

            Code:
            <mvt:foreach iterator="group" array="basket:groups">
            
            <mvt:do name="l.return" file="g.Module_Library_DB" value="Runtime_Product_Load_Code( l.settings:group:code, l.settings:product )" />
            
            <mvt:if expr="l.settings:group:price NE l.settings:product:price">
            Item: &mvte:group:code; Price has changed!
            </mvt:if>
            
            </mvt:foreach>
            This is simply outputting text that the item price has changed. If you wanted to automatically update the price there is a new function we released in 10.03 that makes this much easier:

            Code:
            function Runtime_BasketGroup_Update( group_id, data, callback, delegator )
            {
            return AJAX_Call_JSON( callback, 'runtime', 'Runtime_BasketItem_Update',
            {
            Group_ID: group_id,
            Quantity: data.quantity,
            Subscription_Term_ID: data.subterm_id,
            Attributes: data.attributes
            }, delegator );
            }
            https://docs.miva.com/miva10/referen...mejs-reference
            Hey Brennan,
            We are all upgraded to 10.03, but I am not sure the runtimejs item is available yet. Is there a module that needs to be installed? This just could be me not understanding the new js item and how it integrates. Thanks,
            --Scott

            Comment


              #7
              Originally posted by Brennan View Post
              Here is some example code that just identifies that a product in the basket has a different price. I've seen this request enough to justify us looking to adding this in as a feature/setting in Miva.

              <snip>
              Just to make it easy for everyone, please include a popup notification the user to explain to the customer what happend and require an 'OK' to actually update the price



              Bruce Golub
              Phosphor Media - "Your Success is our Business"

              Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
              phosphormedia.com

              Comment


                #8
                scottd21 For upgraded stores you need to manually create the item and assign it to the pages you want to use the runtime functions on.
                Brennan Heyde
                VP Product
                Miva, Inc.
                [email protected]
                https://www.miva.com

                Comment

                Working...
                X