Announcement

Collapse
No announcement yet.

Price Decimal Place Setting of 0 Messes Up Emailed Order Summary (rounds tax #s)

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

  • Price Decimal Place Setting of 0 Messes Up Emailed Order Summary (rounds tax #s)

    Because we price all our products (jewelry) in rounded dollar amounts, I have our store's Decimal Places on Price (settings > general > store settings > store > regional settings) set to 0; makes for much cleaner category and product pages. Oddly, however, 3dcart applies the setting to dollar amounts within emails the system sends to our clients (Order Summary, for instance, from settings > design > emails > order emails > new order - customer), meaning the emailed amounts are NOT correct. For instance, if tax on an item is 175.75, the emailed summary will round such up to $176, creating an error in that line as well as the total.

    3dcart has internal invoices (orders > manage orders > shipped, for instance) correctly overriding the Decimal Places on Price setting; meaning decimal places show on all invoice amounts, meaning these invoices are correct.

    We need to either (A) have our emailers pull the same figures as these invoices (no decimal filter), or (B) change our store preference to 2 decimal places, then use JS/JQuery to remove the ".00" from store prices (class .product-price) within our website (again, but not email).

    I write neither JS nor JQuery and so, while I can see how this could work, cannot author it myself.

    Anyone care to share how to accomplish either approach?
    Last edited by Pixel Relish; 12-07-2018, 03:32 PM.

  • #2
    You could do something like this on the product pages.

    <p id="Itemprice">[price]</p>

    <script>
    if (1.00) {
    document.getElementById("Itemprice").innerHTML = "1";
    }
    if ([2.00]) {
    document.getElementById("Itemprice").innerHTML = "2";
    }
    </script>

    You'd have to add a lot of lines though

    Comment


    • #3
      Interesting. Could I simplify what your wrote and do an if (.00)... .innerHTML = "" ? Meaning replace .00 with nothing? Or with "&nbsp;" (or however you'd write a nonbreaking space in this syntax)?

      Comment


      • #4
        Originally posted by Pixel Relish View Post
        Interesting. Could I simplify what your wrote and do an if (.00)... .innerHTML = "" ? Meaning replace .00 with nothing? Or with "&nbsp;" (or however you'd write a nonbreaking space in this syntax)?
        Give this a try.



        <script type="text/javascript">
        window.onload = replaceZeros;
        function replaceZeros() { document.body.innerHTML = document.body.innerHTML.replace(/.00/g, ' ');}

        </script>

        Edit: The first script would have only replaced .00 once per instance. This should work for your entire page.




        <script type="text/javascript"> window.onload = replaceZeros;
        function replaceZeros() { document.body.innerHTML = document.body.innerHTML.replace('.00', '');}

        </script>
        Last edited by Toocutebeads; 12-08-2018, 11:55 AM.

        Comment


        • #5
          Thanks! I will test on my sandbox account today.

          Comment


          • #6
            Oddest thing: Works for quick_view template, however on category_ and product_ if I add the script the nav dropdown menus disappear??? On both html pages, I added the script end of template after the defaul scripts for the page.

            Perhaps if we target specifically .main-content or .pricingBlock? To do that, do I have to list the entire string (or whatever it is called) from body to that point in the HTML?
            Last edited by Pixel Relish; 12-10-2018, 11:43 AM.

            Comment


            • #7
              Originally posted by Pixel Relish View Post
              Oddest thing: Works for quick_view template, however on category_ and product_ if I add the script the nav dropdown menus disappear??? On both html pages, I added the script end of template after the defaul scripts for the page.
              Glad it worked. Can you message me your site so I can see how it looks in action.

              Comment


              • #8
                Turns out did not work: See edited, above; messes with dropdown functionality; so odd.

                Comment


                • #9
                  I am testing on my sandbox site, which I do not currently have open to the public (don't want appearing in searches). Our live site is dominiquecohen.com. If you want me to give you viewing access to the testing site, send me your IP address (is it safe for you to post such in a forum?). My sandbox url is http://sandbox-pixel-relish-com.3dcartstores.com.
                  Last edited by Pixel Relish; 12-10-2018, 11:51 AM. Reason: Didn't post full reply

                  Comment


                  • #10
                    Originally posted by Pixel Relish View Post
                    I am testing on my sandbox site, which I do not currently have open to the public (don't want appearing in searches). Our live site is dominiquecohen.com. If you want me to give you viewing access to the testing site, send me your IP address (is it safe for you to post such in a forum?). My sandbox url is http://sandbox-pixel-relish-com.3dcartstores.com.
                    Originally posted by Pixel Relish View Post
                    I am testing on my sandbox site, which I do not currently have open to the public (don't want appearing in searches). Our live site is dominiquecohen.com. If you want me to give you viewing access to the testing site, send me your IP address (is it safe for you to post such in a forum?). My sandbox url is http://sandbox-pixel-relish-com.3dcartstores.com.
                    Alright, I think this should work without conflict. You'll need top add a class to the div, span, or paragraph surrounding the price

                    <span class="HAS-DECIMAL">[price]</span>

                    The script should search for the occurrence of the class, and know only to target that area to replace, which hopefully remove whatever the conflict was. Have a look at the link Ive attached. Good luck.

                    http://jsfiddle.net/u7fr84qm/


                    <script>
                    $(document.body).find('*').each(function() {
                    if($(this).hasClass('HAS-DECIMAL')){
                    $(this).removeClass('HAS-DECIMAL');
                    $(this).addClass('REMOVE-DECIMAL');
                    }
                    var tmp = $(this).children().remove();
                    var text = $(this).text();
                    text = text.replace(/.00/g, " ");
                    $(this).text(text); //setting text
                    $(this).append(tmp);
                    });
                    </script>

                    Forgot to mention, you are correct about the clean way it displays on your main website. Hopefully this is a solution that works.

                    Comment


                    • #11
                      Oddly, that script (the Fiddle version) pasted at the end of the master JS file) removes all #s after the comma; for example, $1,200 becomes $1, Even more oddly, there are a few items for which this doesn't happen??? Happens even before and regardless of if I add the HAS-DECIMAL class to the suitable div, span, h3, whatever. I've been reading the rendered + script over and over and while I understand aspects do not understand the script well enough to follow all in order to find the error. Oh, and pasting the <script>, not the Fiddle version, into the relevant template itself again breaks the nav dropdown functionality. Am I doing something incorrectly, or is the script conflicting with something in the master JS?

                      Comment


                      • #12
                        Originally posted by Pixel Relish View Post
                        Oddly, that script (the Fiddle version) pasted at the end of the master JS file) removes all #s after the comma; for example, $1,200 becomes $1, Even more oddly, there are a few items for which this doesn't happen??? Happens even before and regardless of if I add the HAS-DECIMAL class to the suitable div, span, h3, whatever. I've been reading the rendered + script over and over and while I understand aspects do not understand the script well enough to follow all in order to find the error. Oh, and pasting the <script>, not the Fiddle version, into the relevant template itself again breaks the nav dropdown functionality. Am I doing something incorrectly, or is the script conflicting with something in the master JS?
                        Ok, try by findings any <span class="HAS-DECIMAL"> I was able to get this to run on my site without issue. Hopefully this stops any possible conflicts because it should only apply to a span surrounding the price, with that specific tag.

                        <script>
                        $(document.body).find('span.HAS-DECIMAL').each(function() {
                        if($(this).hasClass('HAS-DECIMAL')){
                        $(this).removeClass('HAS-DECIMAL');
                        $(this).addClass('REMOVE-DECIMAL');
                        }
                        var tmp = $(this).children().remove();
                        var text = $(this).text();
                        text = text.replace(/.00/g, " ");
                        $(this).text(text); //setting text
                        $(this).append(tmp);
                        });
                        </script>

                        Comment


                        • #13
                          Ok, I figured out why its not working for you. I don't have any products in the hundreds or thousands, so the replace string is replacing ,00 or 00 or .00 as its all the same. I'll have to add a 1,000 product to see where I'm going wrong here.

                          Comment


                          • #14
                            This should account for the , and extra zeros

                            https://jsfiddle.net/1a4x68ks/

                            $(document.body).find('span.HAS-DECIMAL').each(function() {
                            if($(this).hasClass('HAS-DECIMAL')){
                            $(this).removeClass('HAS-DECIMAL');
                            $(this).addClass('REMOVE-DECIMAL');
                            }
                            var tmp = $(this).children().remove();
                            var text = $(this).text();
                            text = text.replace(/\.00$/,'');
                            $(this).text(text); //setting text
                            $(this).append(tmp);
                            });

                            Comment


                            • #15
                              Thank you sooooo much: The above appears to work! I have a couple more templates to test, then will move all over to the live site, hopefully by no later than 3 PM PST, if you want to check out.

                              I seriously appreciate your help. 3dcart Support won't even admit that the way they have things set up is throwing an error by affecting [otax] figures within email templates (as mentioned, the decimal setting should never have been applied to tax values, because rarely will such end in .00, and rounding up or down is incorrect); Support acts as if I'm asking them to do something special for us rather than simply fix an error in their system. Been very frustrating.

                              Glad to be able to remove the warning I had to add to our email template directing people to download their receipt rather than relying on the accuracy of email summary figures. Made us look like such idiots!
                              Last edited by Pixel Relish; 12-11-2018, 04:17 PM.

                              Comment

                              Working...
                              X