Announcement

Collapse
No announcement yet.

Discount on total quantity

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

    Discount on total quantity

    Need to calculate a discount based on total quantity purchased, but my perl skills are not that good.


    I know that the change needs to go into AdjustmentTemplate.pl and I can do most of the required changes. However I cannot work out how to pull in the running quatity total variable (CartItem) that appears at the top of the cart pages.

    Have taken this over from MTD, who could not resolve it.

    Can anyone give me a pointer?

    Many thanks.

    #2
    Hi Steve

    Is it the number of items in the cart you want to base the discount on, or the total value of items in the cart? If it's the value, you can set the discounts in the UI under View | Discounts.

    Ben
    Ben Popplestone
    Ecommerce website software

    Comment


      #3
      Ben

      It is the total quatity that I need. I know how to discount against the total value.

      I am implementing an online wine sales system. I need to offer a discount once the total number of bottles exceeds 12 (i.e. a case).

      I just need to be able to call in the Cart Item variable (into AdjustmentTemplate.pl) that is displayed at the top of the page.

      Thanks in anticipation.

      Regards Steve

      Comment


        #4
        Ok, I'll ask development to have a look at this.
        Ben Popplestone
        Ecommerce website software

        Comment


          #5
          Thanks Ben.

          Comment


            #6
            Hmmm... It doesn't look like a simple issue what we can do within the frame of support. Anyway I'm going to check and post at least some pointers.
            However I cannot work out how to pull in the running quatity total variable
            It is Cart::CountQuantities()

            Regards,
            Zoltan
            Actinic Software
            www.actinic.co.uk

            Comment


              #7
              Ok, lets try the following code. Just add it to the end of AdjustmentTemplate.pl above the return statement.
              Code:
              	#
              	# Get a reference of the cart object first
              	#
              	my @Response = $::Session->GetCartObject();
              	if ($Response[0] != $::SUCCESS)					# general error
              		{
              		return($::SUCCESS, '', \@arrAdjustments);
              		}
              	my $pCartObject = $Response[2];
              	my $pCartList = $pCartObject->GetCartList();
              	#
              	# Get the total item count from the cart
              	#
              	my $nCount = $pCartObject->CountQuantities();
              	#
              	# Now set up the quantity discount
              	#
              	my $nLimit = 3;
              	my $nAdjustment = -2500 * int($nCount/$nLimit);
              	my $sCaption = "The discount name in the cart";
              	#
              	# And check if this qualifies
              	#
              	if ($nCount >= $nLimit &&
              		 scalar(@$parrOrderTotals) == 2)
              		{
              		my @arrAdjustment = 
              			($sCaption, 
              			$nAdjustment, 
              			$::eAdjTaxProRataAdjusted,
              			"",
              			0);
              		push @arrAdjustments, \@arrAdjustment;	
              		}		
              	return($::SUCCESS, '', \@arrAdjustments);
              Obviously you can customise this. Try to edit the followings:
              • $nLimit to change the triggering quantity. Actually the discount is triggered if there are 3 items in the cart. You can change the number 3 to whatever you wish (e.g. 12 ).
              • $nAdjustment to change the discount value. Actually this adds 25GBP discount to the cart for each 3 items. If you wish to have only one discount above the triggering quantity (and not for each 3) then remove the *int(...) part of that line. Percentage discounts can also be created just let me know if you require details about this.
              • $sCaption to customise the text which appears in the cart as discount description.
              I hope this helps. Enjoy.
              Zoltan
              Actinic Software
              www.actinic.co.uk

              Comment


                #8
                zmagyar

                You are a star!

                The code was not exactly what I needed, but it opened the door and provided the template.

                The site now offers two levels of discount. 2.5% on 6 -11 bottles. 5% on 12 or more bottles.

                Thanks for your help.

                Regards Steve

                Comment

                Working...
                X