Announcement

Collapse
No announcement yet.

getMinicart issue

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

    getMinicart issue

    Hi

    Going back on an old post which enables the cart to display product names and total. I am having some difficulty getting this working correctly and wonder if anybody who did get it working might be able to lend a hand! The original thread is

    http://community.actinic.com/showthr...light=getfullc

    The instructions seem straighforward except I am getting a "Surcharges" being shown in the cart with a value in 6 figures!! as well as shipping cost (which I do not want to show).

    #2
    repeat the instructions again carefully as they are correct

    Comment


      #3
      Hi

      Thanks for the reply. I have tried it a few times already and just tried once more with somebody checking what I did. Sadly, I still get the same results.

      Any help or ideas really appreciated.

      Comment


        #4
        You can't really expect us to make guesses on what's gone wrong. If you want people to help you're going to have to give us a url so we can look at it.

        Mike
        -----------------------------------------

        First Tackle - Fly Fishing and Game Angling

        -----------------------------------------

        Comment


          #5
          Hi

          Good point.

          I have made the changes again this mornign and uploaded to site. You can see the issue only on a test homepage (site is adult).

          http://www.purplepleasures.com/hometest.html (this is a non catalogue page)

          If you enter store and add something to cart, then return to the test homepage, you should see the issues. Shipping and Surcharges are being shown (and at a massive cost, which would be nice), also the display of cart content is to large and is ignoring the "class=" command.

          Any thoughts and comments welcomed.

          Comment


            #6
            Not sure about the shipping/surcharges issue. What shipping model are you using in Actinic?

            The cart content is using .mainbody as the inherited style. There is no class on the links or anything else within the minicart.

            .mainbody{
            color:#330066;
            font-family:Tahoma,Verdana,Arial;
            font-size:12px;
            }
            Fergus Weir - teclan ltd
            Ecommerce Digital Marketing

            SellerDeck Responsive Web Design

            SellerDeck Hosting
            SellerDeck Digital Marketing

            Comment


              #7
              We are using a simple shipping method Zone and Class. and based on cart value. I have tried adding <span class=mainbody> around the line to display cart content <script type="text/javascript">document.write(getMiniCart());</script> but I can't work out why it is not having the desired effect.

              Comment


                #8
                Your minicart total seems to be 10,000 times what's expected. Perhaps you're multiplying by 100 somewhere instead of dividing by 100.
                Norman - www.drillpine.biz
                Edinburgh, U K / Bitez, Turkey

                Comment


                  #9
                  I was about to post the same as Norman.

                  The 'surcharge' is the total, but 1,000 times to large.

                  Best to copy and paste the mini-cart code you're using into the forum if you can't find the error.

                  Mike

                  Edit: OK here's the mini-cart JS being used.

                  /***********************************************************************
                  *
                  * getMiniCart - fetches cart content summary
                  *
                  * Returns: - HTML string for summary display
                  *
                  * Graham Bradley 2007
                  * Comments & bug reports to web@gbradley.co.uk
                  *
                  * To make editing the output HTML easier, output code has been split into
                  * nine 'template' strings.
                  *
                  * tableOpen - the opening table code
                  * itemLine - repeated for each item in the cart
                  * shippingLine - for displaying shipping charges (if any)
                  * vatLine - for displaying VAT on items & shipping (if any)
                  * discountLine - for displaying discount total (if any)
                  * surchargeLine - for displaying surcharge total (if any)
                  * totalLine - for displaying the cart total
                  * tableClose - the closing table code
                  * emptyLine - displayed when cart is empty
                  *
                  * Within these templates, you can use variables to insert values into
                  * the summary, similar to variables in Actinic:
                  *
                  * VAR:QUANTITY - The quantity of item in cart
                  * VAR:TITLE - Abbreviated name of item
                  * VAR:LINK - URL of item via the cgi-bin
                  * VAR:PRICE - Formatted price of item
                  * VAR:SHIPPING - Total of shipping applied
                  * VAR:VAT - Total VAT on cart items & shipping
                  * VARISCOUNT - Total of discounts applied
                  * VAR:SURCHARGE - Total of surcharges applied
                  * VAR:TOTAL - Grand total
                  *
                  * Variables can only be used in the templates in which they are found.
                  *
                  ************************************************************************/

                  function getMiniCart(){

                  var tableOpen="<table width='100%'>";
                  var itemLine="<tr><td valign='top'>VAR:QUANTITYx </td><td><a href='VAR:LINK'>VAR:TITLE...</a></td><td align='right' valign='top'>VAR:PRICE</td></tr>"
                  var shippingLine="<tr><td colspan='2'>Shipping</td><td align='right'>VAR:SHIPPING</td></tr>"
                  var vatLine="<tr><td colspan='2'>VAT</td><td align='right'>VAR:VAT</td></tr>"
                  var discountLine="<tr><td colspan='2'>Discounts</td><td align='right'>VARISCOUNT</td></tr>"
                  var surchargeLine="<tr><td colspan='2'>Surcharges</td><td align='right'>VAR:SURCHARGE</td></tr>"
                  var totalLine="</table><table width='100%'><tr><td><b>Total</b></td><td align='right'><b>VAR:TOTAL</b></td></tr>"
                  var tableClose="</table>"
                  var emptyLine="Your basket is empty";

                  var cookie=getCartItem(4);

                  if (!cookie){
                  return emptyLine;
                  }
                  var re=new Array();
                  var match=new Array();
                  var total=0;
                  var str;
                  re[1]=/cur=([^&]*)&!/g;
                  re[2]=/&!(.*)/g;
                  re[3]=/ss=(.*)cur=/i;
                  re[4]=/tx=(.*)sh=/i;
                  re[5]=/sh=(.*)ss=/i;
                  for (i=1;i<re.length;i++){
                  match[i]=re[i].exec(cookie);
                  match[i]=match[i][1];
                  }
                  lines=match[2].split("&!");
                  store=new Array();
                  re[0]=/^(\d*)x/;
                  re[1]=/x([^>]*)>/;
                  re[2]=/>([^>]*)>/;
                  re[3]=/>([^>]*)$/;
                  str=tableOpen;
                  for (i=0;i<lines.length;i++){
                  for (j=0;j<re.length-2;j++){
                  detail=lines[i].match(re[j]);
                  store[j]=detail[1];
                  }
                  str+=itemLine.replace("VAR:QUANTITY",store[0]).replace("VAR:LINK",match[3]+"?PRODREF="+store[1]+"&NOLOGIN=1").replace("VAR:TITLE",store[2]).replace("VAR:PRICE",match[1]+((store[3]*1).toFixed(2)));
                  total+=(store[3]*1);
                  }
                  if (match[5] > 0){
                  str+=shippingLine.replace("VAR:SHIPPING",match[1]+(match[5]/100).toFixed(2));
                  total=total+=(match[5]/100);
                  }
                  if (match[4] > 0){
                  str+=vatLine.replace("VAR:VAT",match[1]+(match[4]/100).toFixed(2));
                  total=total+=(match[4]/100);
                  }
                  gTotal=getCartItem(1);
                  var r=/&#(\d*);/gi;
                  var m=new Array();
                  var f=new Array();
                  while((m = r.exec(gTotal))!=null){
                  f[f.length]=m[1];
                  }
                  for (i=0;i<f.length;i++){
                  gTotal=gTotal.replace("&#"+f[i]+";","");
                  }
                  total=total.toFixed(2);
                  gTotal=(gTotal/100).toFixed(2);
                  if (total>gTotal){
                  str=str+=discountLine.replace("VARISCOUNT","-"+match[1]+(total-gTotal).toFixed(2));
                  }
                  else if (total<gTotal){
                  str=str+=surchargeLine.replace("VAR:SURCHARGE",match[1]+(gTotal-total).toFixed(2));
                  }
                  str+=totalLine.replace("VAR:TOTAL",match[1]+(gTotal));
                  str+=tableClose;
                  return str;
                  }
                  -----------------------------------------

                  First Tackle - Fly Fishing and Game Angling

                  -----------------------------------------

                  Comment


                    #10
                    Mike,

                    Unfortunately the forum munges any & # 1 2 3 ; text so the above code may not be accurate.
                    Norman - www.drillpine.biz
                    Edinburgh, U K / Bitez, Turkey

                    Comment


                      #11
                      John,
                      Re: the styling issue: You could wrap a span around the text rather than using the TD class defintion.

                      e.g.

                      <span class="mainbody">Surcharges</span>
                      Fergus Weir - teclan ltd
                      Ecommerce Digital Marketing

                      SellerDeck Responsive Web Design

                      SellerDeck Hosting
                      SellerDeck Digital Marketing

                      Comment


                        #12
                        Looking at it I can't see anything obviously wrong. But then very little of it makes any sense to me.

                        I can see where teh problem must lie though. the Grand total is 10,000 too large so it automatically creates a 'surcharge' item to allow for the difference between the grand total and the total.

                        So as Norman says, the most likely cause is that it isn't being divided by 100 but is being multiplied instead.

                        Not obvious to though where this is happening.

                        Mike
                        -----------------------------------------

                        First Tackle - Fly Fishing and Game Angling

                        -----------------------------------------

                        Comment


                          #13
                          John,

                          If you put the following into your test page, it will display what's in the cookie that this patch uses and may help.
                          Code:
                          <script>document.write(document.cookie + '<br><br>' + unescape(document.cookie));</script>
                          It displays the cookie twice. Once as-is and the again but escaped for easier reading.

                          If you're putting it into an Actinic product description surround it with !!< and >!! so it gets inserted as code.
                          Norman - www.drillpine.biz
                          Edinburgh, U K / Bitez, Turkey

                          Comment


                            #14
                            Hi

                            Thank you.

                            I have added the Cart.pm, ActinicOrder.pm & ActinicExtras.js which are the 3 files that are modified to http://www.purplepleasures.com/minicart/

                            Comment


                              #15
                              Hi Norman

                              I have added the line you suggest and you can see it here

                              http://www.purplepleasures.com/hometest.html

                              Somewhat beyond my technical skills though!

                              Comment

                              Working...
                              X