Announcement

Collapse
No announcement yet.

Highlighting The Discount Band

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

    Highlighting The Discount Band

    Im hoping someone here can offer some help, on this site http://www.casupply.co.uk/ i have a discount structure info box setup in the left hand side bar below the navigation, in the checkout pages i have removed the navigation so this sits at the top.

    what i am after is a way to highlight the discount band according to the value in there shopping basket. I know this is not going to be an easy one but any help or pointers would be greatly appreciated.

    This site here has what im looking for http://www.aluminiumwarehouse.co.uk/index.html

    Cheers
    Darren
    __________________

    #2
    You can do this with JavaScript. The tricky bit is getting the Cart total into a numeric form so you can do some comparison on it. Use:
    Code:
    var carttotal = getCartItem(1).toString().replace(/./g, '.').replace(/&#\d+;/g, '') - 0;
    Norman - www.drillpine.biz
    Edinburgh, U K / Bitez, Turkey

    Comment


      #3
      Then what you do is something like this:
      Code:
      <span id="less5">£200 - £399.99 Less 5%</span><br/>
      <span id="less10">£400 - £599.99 Less 10%</span><br/>
      <span id="less15">£600 - £999.99 Less 15%</span><br/>
      <span id="less20">£1000 % Over Less 20%</span><br/>
      
      <style>.discbold {font-weight: bold; color: blue;}</style>
      <script type="text/javascript">
      var carttotal = getCartItem(1).toString().replace(/&#38;#46;/g, '.').replace(/&#38;#\d+;/g, '') - 0;
      if ( carttotal >= 200 && carttotal < 400 ) document.getElementById('less5').className='discbold';
      if ( carttotal >= 400 && carttotal < 600 ) document.getElementById('less10').className='discbold';
      if ( carttotal >= 600 && carttotal < 1000 ) document.getElementById('less15').className='discbold';
      if ( carttotal >= 1000 ) document.getElementById('less20').className='discbold';
      </script>
      Norman - www.drillpine.biz
      Edinburgh, U K / Bitez, Turkey

      Comment


        #4
        Thanks Norman i will give it a go now and see what happens

        As always your help is much appreciated

        Darren

        Comment


          #5
          Everything worked great but is there a variable for the sub total (net price) as the discount bands work on net value.

          Thanks again
          Darren

          Comment


            #6
            Hmmmm

            OK i have adjusted the range to the price including VAT this works until you start to mess with the quatities in your shopping cart as the discount changes between bands it does not show the correct value.

            Is there anywere on the checkout pages that you can find the total net price before any discounts have been applied, i mean a hidden variable or something similar

            Cheers
            Darren

            Comment


              #7
              The only thing available in real-time is the total cart value. This may / may not include shipping and VAT depending on your system configuration. It probably includes discounts so there will be problems (£200 less 5% is the same as £190 with no discount).

              There's no way to get at any other info without hacking the Perl and that's a big job.
              Norman - www.drillpine.biz
              Edinburgh, U K / Bitez, Turkey

              Comment


                #8
                O.K. Here is the Perl tweak that extends the Cart cookie to contain the Cart sub-total.

                Edit ActinicOrder.pm (back it up first) and look for:
                Code:
                sub GenerateCartCookie
                Replace that entire routine i.e.
                Code:
                sub GenerateCartCookie
                	{
                .
                .
                .
                	return($sCookie);
                	}
                With the following:
                Code:
                sub GenerateCartCookie
                	{
                	#
                	#Set the default cookie content
                	#
                	my $sCookie =  "CART_TOTAL\t0\tCART_COUNT\t0\tCART_SUBTOTAL\t0\n";
                	#
                	# Read the shopping cart
                	#
                	my @Response = $::Session->GetCartObject();
                	if ($Response[0] != $::SUCCESS)					# general error
                		{
                		return ("CART_CONTENT=". ACTINIC::EncodeText2($sCookie,0));	# empty cart so return empty string
                		}
                	my $pCartObject = $Response[2];
                
                	my $pCartList = $pCartObject->GetCartList();
                	#
                	# Get item count
                	#
                	my $nCount = $pCartObject->CountQuantities();
                	if ($nCount <= 0)
                		{
                		return ("CART_CONTENT=". ACTINIC::EncodeText2($sCookie,0));	# empty cart so return empty string
                		}
                	#
                	# Summarize order
                	#
                	 @Response = $pCartObject->SummarizeOrder($::TRUE);# calculate the order total
                	if ($Response[0] != $::SUCCESS)
                		{
                		return ("CART_CONTENT=". ACTINIC::EncodeText2($sCookie,0));
                		}
                	my $nTotal = $Response[6];
                
                	my $nSubTotal = $Response[2];
                	#
                	# Format sub-total price
                	#
                	@Response = ActinicOrder::FormatPrice($nSubTotal, $::TRUE, $::g_pCatalogBlob);	# Format current sub-total
                	if ($Response[0] != $::SUCCESS)
                		{
                		return ("CART_CONTENT=". ACTINIC::EncodeText2($sCookie,0));
                		}
                	my $sSubTotal = $Response[2];
                	
                	#
                	# Format price
                	#
                	@Response = ActinicOrder::FormatPrice($nTotal, $::TRUE, $::g_pCatalogBlob);	# Format current total
                	if ($Response[0] != $::SUCCESS)
                		{
                		return ("CART_CONTENT=". ACTINIC::EncodeText2($sCookie,0));
                		}
                	my $sTotal = $Response[2];
                	#
                	# Create Cookie string
                	#
                	$sCookie =  "CART_TOTAL\t" . ACTINIC::EncodeText2($sTotal) 
                		. "\tCART_COUNT\t" . ACTINIC::EncodeText2($nCount)
                		. "\tCART_SUBTOTAL\t" . ACTINIC::EncodeText2($sSubTotal) . "\n";
                	$sCookie = "CART_CONTENT=" . ACTINIC::EncodeText2($sCookie,0);
                	return($sCookie);
                	}
                Now, in post #3 above replace getCartItem(1) with getCartItem(5) to use the sub-total.
                Norman - www.drillpine.biz
                Edinburgh, U K / Bitez, Turkey

                Comment


                  #9
                  thanks Norman,running out of time today, i will take a peek tomorrow and feed back how i get on

                  Cheers
                  Darren

                  Comment


                    #10
                    I have done your hack today thanks Norman it works a treat

                    if you want to see it then you can here http://www.cabp.co.uk

                    Thank you so much for the assistance
                    Darren

                    Comment


                      #11
                      OK me again

                      I have been trying to add a background image to the highlight but without success can someone tell em what i have wrong here the background colour works but not the image

                      Code:
                      {color: white; background-image: url('discount_background.gif'); background-color: #800000;}</
                      Cheers
                      Darren

                      Comment


                        #12
                        Originally posted by NormanRouxel View Post
                        There's no way to get at any other info without hacking the Perl and that's a big job.
                        Originally posted by NormanRouxel View Post
                        O.K. Here is the Perl tweak that extends the Cart cookie to contain the Cart sub-total.
                        Norman likes a challenge then! LOL
                        "If my answers frighten you then you should cease asking scary questions"

                        Comment


                          #13
                          A big job if you don't know where to start as there's nearly 2Mb of Perl source, split over about 34 files!

                          Luckily, experience told me it would be in ActinicOrder.pm and a quick search for "cookie" got me close. After that it was pretty much a copy / tweak / paste job.

                          It might be worth Actinic adding this in a future release as it extends the cart contents cookie without changing any existing functionality.
                          Norman - www.drillpine.biz
                          Edinburgh, U K / Bitez, Turkey

                          Comment


                            #14
                            Darren,

                            I'm not sure if you're getting the correct display. My tweak was for discounts using the Marketing / Discounts / Order Level method. This applies the discount after the sub-total.

                            You seem to be using a different method and your sub-total is calculated after the discount is applied.

                            You may need to adjust the values used in the set of if statements to use the discounted prices.
                            Norman - www.drillpine.biz
                            Edinburgh, U K / Bitez, Turkey

                            Comment


                              #15
                              i had thought it was working ok but on close examination your right when its around the figure it can show the wrong band.

                              the discount i am using is on cart contents (restricted to certain product groups)

                              Comment

                              Working...
                              X