Jump to content

Small piece of code help..


Guest modowl

Recommended Posts

Guest modowl

Hi ALl,

I have posted this here also:

http://www.cubecart.org/forums/index.php?showtopic=450

But I have had no response.

I don't know if anyone can help me do this:

I am looking for a small piece of PHP code to show the total tax charged.

I cannot use the standard CubeCart way of doing things for various reasons.

Basically the code is one line that will take the carts "Grand Total"+"Shipping" total and make a calculation based apon the Tax rate.

So EG:

Grand Total = 100

Shipping = 20

Tax = 10%

Line of code will then produce a line of text on the checkout page that says:

"Total Tax charged on this order = $12"

Based apon the calculation above.

This should be easier enough for someone who knows PHP?

PayPal is at the ready!

Sir William, Kindly suggested the code below but I am confused at how to implement it.

$taxRate = 10;

$totalTax = number_format((($grandTotal + $shipping) * $taxRate/100), 2, '.', ',')

Link to comment
Share on other sites

Hi Modowl

SW code is correct... Let me explain

This is the tax rate of 10%

$taxRate = 10;

number_format is a PHP function that will return a number in a certain format eg.

$number = 1234.56;

english notation (default)

$english_format_number = number_format($number);

this returns 1,235

$number = 1234.5678;

english notation without thousands seperator

$english_format_number = number_format($number, 2, '.', '');

this returns 1234.57

So using SW's code instead of called a number it is canculating a number then formating it.

$totalTax = number_format((($grandTotal + $shipping) * $taxRate/100), 2, '.', ',')

Just enter this code into the correct place in the checkout scripts and call the variable $totalTax where you want it to appear.

A

Link to comment
Share on other sites

Guest walmarc

Just enter this code into the correct place in the checkout scripts and call the variable $totalTax where you want it to appear.

A

In the .org forum, EvilHomeR said to enter it "in the shopping cart page". I have no idea which php file that is.

I've offered to pay for a solution because this would greatly help my store also. i.e. Where is the "correct place" :blink:

Link to comment
Share on other sites

Hi All

You need to add the following code at line 155 in skins/xxxx/styleTemplates/content/cart.tpl

<tr>

<td colspan="7" align="right">{LANG_TAX}</td>

<td width="80" align="right">{VAL_TOTAL_TAX}</td>

</tr>




AND add the following code at line 368 in includes/content/cart.inc.php




$taxRate = 10;

$totalTax = number_format((($grandTotal + $shippingPrice) * $taxRate/100), 2, '.', ',');

$view_cart->assign("VAL_TOTAL_TAX",priceFormat($totalTax));

Linenumber may be different but I am using a modded legend skin.

Let me know if this helps...

A

Link to comment
Share on other sites

Guest modowl

Hi A,

Thanks a lot for the reply.

I have inserted the code into skins/xxxx/styleTemplates/content/cart.tpl and have removed the old TAX <TR>

I am a bit lost where to insert the code into includes/content/cart.inc.php.

I have tried and the TAX is showing as zero (0.00)...If I don't insert the code into cart.inc.php it shows as blank, So I know it is trying to use the code from cart.inc.php but for some reason it is not working.

I think this is as I am inserting it in the wrong place.

Could you give us the code either side of where you have inserted it so we can track down where the correct line is?

Thanks a lot for your help!

Link to comment
Share on other sites

Guest modowl

Hi A,

GReat thanks a lot, That works great.

Basically the code in cart.inc.php needs to be inserted after the line:

$grandTotal = $subTotal + $tax + $basket['shipCost'];

For me this is line 636.

I am going to be trying soon to add this to the emails etc.

I will start a new post for that!

Thanks again and let me know your PayPal info so I can buy you a beer for the weekend =)

Link to comment
Share on other sites

Guest walmarc

Hi A,

GReat thanks a lot, That works great.

Basically the code in cart.inc.php needs to be inserted after the line:

$grandTotal = $subTotal + $tax + $basket['shipCost'];

For me this is line 636.

I am going to be trying soon to add this to the emails etc.

I will start a new post for that!

Thanks again and let me know your PayPal info so I can buy you a beer for the weekend =)

Haven't tried it yet but if it works for me PM your paypal info and I'll send you GBP5 for your help.

Thanks

Link to comment
Share on other sites

  • 5 weeks later...
Guest BigNaz

I have tried implementing this mod, but with no great joy...

I found that you have to set your standard tax rate to zero to get the correct figures on the checkout, and it does not provide the relevant variables for creating the print order form etc.

Is there a more comprehensive mod available anywhere??

Link to comment
Share on other sites

Guest walmarc

I have tried implementing this mod, but with no great joy...

I found that you have to set your standard tax rate to zero to get the correct figures on the checkout, and it does not provide the relevant variables for creating the print order form etc.

Is there a more comprehensive mod available anywhere??

I had a mod completed recently on 3.0.10 that included a working tax mod of this sort with carry through to the print_order_form+ a couple of other payment modules + the auto-emails to Admin & Customer.. I feel sure the author will be able to adapt it for your needs - he's a genius! (I can't say how much it would cost you). You could PM me for details (I think I need to ask his permission before I can name him) or go to cc3.biz and look under "Value Added Sevices". I haven't checked if there is one available on cubecart.org. You should probably search there first under both free and commercial mods. :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...