Announcement

Collapse
No announcement yet.

Help with Overriding Price Calculations in Checkout Process

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

    Help with Overriding Price Calculations in Checkout Process

    I am still a Novice with Miva, so I will try to explain this as best I can.

    My store owner has requested that all pricing be rounded to the floor of its value after the price group discount has been applied. (ie...25%, 30%, 40%)
    The idea being that there will never be anything after the decimal point. (ie...$275.25 = $275.00 or $363.75 = $363.00).
    • I have been able to create custom logic using Miva/Toolkit Math Functions in the MiniBasket, Basket pages & the Basket Summary to display these calculations correctly, which looks something like this:

    <mvt:foreach iterator="group" array="basket:groups">
    <mvt:assign name="g.discround" value="floor( l.settings:group:price )" />
    <mvt:item name="toolkit" param="math_multiply|lineoprice|g.discround|l.all_ settings:group:quantity" />
    <mvt:item name="toolkit" param="math_add|basketsubtotal|basketsubtotal|line oprice" />

    <mvt:do name="g.formatted_basketsubtotal" file="g.Module_Root $ g.Store:currncy_mod:module" value="CurrencyModule_AddFormatting( g.Store:currncy_mod, g.basketsubtotal )" />

    &mvt:global:formatted_basketsubtotal;
    • or:

    <mvt:foreach iterator="item" array="global_minibasket:groups">
    <mvt:assign name="g.minibaskround" value="floor( l.settings:item:price )" />
    <mvt:item name="toolkit" param="math_multiply|lineoprice|g.minibaskround|l. all_settings:item:quantity" />
    <mvt:item name="toolkit" param="math_add|minibaskettotal|minibasketsubtotal |lineoprice" />

    <mvt:do name="g.formatted_minibaskettotal" file="g.Module_Root $ g.Store:currncy_mod:module" value="CurrencyModule_AddFormatting( g.Store:currncy_mod, g.minibaskettotal )" />

    &mvt:global:formatted_minibaskettotal;
    • And then Adding shipping charge in the Basket Summary and Final Total:

    <mvt:assign name="g.minitotaftship" value="( g.minibaskettotal + l.settings:basket:charges[1]:amount )" />

    <mvt:do name="g.formatted_totaftship" file="g.Module_Root $ g.Store:currncy_mod:module" value="CurrencyModule_AddFormatting( g.Store:currncy_mod, g.totaftship )" />

    &mvt:global:formatted_totaftship;

    All of this works, and all calculations are generated & displayed correctly. These show pricing correctly all the way through to the (OCST) Page, which is the hurdle I so badly need to overcome. I need these variables that I have created to be applied to the amount that is processed when the customer hits the "Complete Order" button. I can get these values to show on the Invoice page, but I really need this corrected amount to be the value that is processed when the payment is captured.

    I am using the Shadows Ready Theme and I have the site set up so that no one can access unless they have a Username & Password. The purpose of the site is to be a Wholesale Ordering Portal for our Wholesale Accounts. If anyone has any advise or can point me in the right direction, it would be greatly appreciated. i realize this probably not something that will be easy to do, I'm just hoping that it can actually be done.

    Thank you all. This is my first post in the Forums.

    #2
    If i understand this correctly:

    1) you're doing it the hard way :)
    You don't need to calculate any of those values. If all you are doing is for display (you can't effect actual prices without considerable work), then just use this:

    <mvt:assign name="g.myLineItemValue" value="getoken(l.settings:basket:items:formatted_s ubtotal, '.', 1)$'.00' />

    in the product loop and things like

    <mvt:assign name="g.myTotalValue" value="getoken(l.settings:basket:formatted_total, '.', 1)$'.00' />

    for the total.

    2) If you haven't installed and used the Token viewer (which shows the variable names available on the page), go to Utilities, Add/Remove Modules and add it. It will now appear under the "More" button menu on the far right side of the screen.

    3) You just need to make those changes to the Basket Summary templates. For Shadows, they might be in ReadyTheme content containers.
    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


      #3
      Thank you so much for your response Bruce, I really appreciate it.

      I wish I was just doing it for display, that I have already accomplished. According to your example, it seems I did do it the hard way.

      What I really need to do is effect the actual prices so that my rounded down price calculations actually get passed through checkout. I had a feeling this would take considerable work, which I am willing to do. But for now, in respect to effecting the actual price total, I don't know where to start.

      Comment


        #4
        RE: Actually changing data values.

        That's going to take a custom module...or at least should. I suppose you might be able to do it using SMT Code...but I wouldn't attempt to do it that way. You'd need to use SMT functions such as

        <mvt:do file="g.Module_Library_DB" name="l.success" value="Basket_Load_ID(basket_id, basket var)" /> to get the contents of the basket, do all your calculations then update with:
        <mvt:do file="g.Module_Library_DB" name="l.success" value="Basket_Update_Order(basket var)" />
        If you did do this with a module, then your other efforts wouldn't be needed as you'd just make the changes before the results are processed to the page.
        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


          #5
          Thank you again Bruce!

          I think I'm going to try the custom module idea and see what I can come up with.

          I was really hoping to find some way to do this without my previous efforts, so that would be great.

          Your responses are much appreciated.

          Comment


            #6
            Dustin SDTW If you're handy with MySQL you could manipulate values in the basket like that. https://github.com/ghassani/miva-sql-component --of course thats pretty advanced if you're not. But If you are and there is no logical miva API to call then sometimes I find a quick SQL magic wand trick does exactly what I need.
            Colin Puttick
            Miva Web Developer @ Glendale Designs

            Comment


              #7
              dreamingdigital I just noticed your suggestion. I will have to look into this! Thank you for your response. If I am being honest, I am not all that advanced in MySQL. I was hoping to find an example somewhere, as I am very good at deciphering and modifying how things work. I will do my research regarding that Miva SQL Component. All I am trying to do is have my price per item rounded down to the floor of its number after the price level discount percentage is applied, so there is never any change left over in the total amount. I wish rounding was an option in the price level settings, other than that it works great for what I am trying to do.

              Comment

              Working...
              X