- Posts: 36
- Thank you received: 0
Cart page : add donation line
-- HikaShop version -- : 2.6.0
-- Joomla version -- : 3.4.5
Hello,
I add a line just above the total line on the cart page.
I already add the html part :
<td id="hikashop_checkout_donation_title" class="hikashop_checkout_donation_title">
<?php echo JText::_('HIKASHOP_DONATION'); ?>
</td>
<td>
<form method="post">
<input type="number" name="donation" style="width:30%" value="0" min="0">
<input type="submit" value="Ok">
</form>
</td>
Then I recover the value here :
<td class="hikashop_cart_total_value" data-title="<?php echo Jtext::_('HIKASHOP_TOTAL'); ?>">
<span class="hikashop_checkout_cart_final_total">
<?php
$total = $this->currencyHelper->format($this->full_total->prices[0]->price_value_with_tax,$this->full_total->prices[0]->price_currency_id);
if (isset($_POST["donation"]))
$total += $_POST["donation"];
echo $total;
?>
</span>
</td>
So the client enter the price and press enter or click on the button "Ok".
The page refresh and print the new price, but instead of print the price for example : 32,42 €
It print only : 32
And I don't know how to correct this...
And for the mail sent to the client and vendor I want to also put the donation line to inform them.
But how can I send and retrieve the value to the file where I custom the mail sent ?
Thank you,
Please Log in or Create an account to join the conversation.
You should add the donation before the call to the format function. For example:
The emails can be edited via the menu System>Emails with the Business edition.
Otherwise, you have to directly edit the files in the folder media/com_hikashop/mail/
Please Log in or Create an account to join the conversation.
How can I use $_SESSION to store the donation value ?
Yes I know where to edit this
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
The file I edit is cart.php from the views hikashop/checkout/joomspirit_76.
It says to replace session_start() with the code but I don't find session_start().
Should I place it below the line at the beginning of the file ?
defined('_JEXEC') or die('Restricted access');
Which path should I add to this line ? :
The path to the cart.php file ?define( 'JPATH_BASE', realpath(dirname(__FILE__).'/../..' ));
I tried
but it doesn't work.../components/com_hikashop/views/checkout/tmpl
Regards,
Please Log in or Create an account to join the conversation.
So you can set it like that:
and then use it like you would use $_POST. The great thing is that once you set it, you can use it anywhere, even on other pages after that.
Please Log in or Create an account to join the conversation.
But when I go the the file where I can edit the mails sent to the client ? I can't display the value of $_SESSION;
How can the program know for which command is the donation ?
Please Log in or Create an account to join the conversation.
You can edit the emails via the menu System>Emails.
There, in the "HTML version" area, you can use such code:
Please Log in or Create an account to join the conversation.
Even the total is wrong it doesn't add the donation value.
Please Log in or Create an account to join the conversation.
That's normal that the total doesn't change. With the code you did before, you simply change the total displayed on the checkout, but not the total in the database.
What you need to do is a small HikaShop plugin implement the onAfterCartProductsLoad(&$cart) trigger of HikaShop in order to set the donation value as an additional in the $cart->additional array.
The system will then add it to the display automatically everywhere.
An example of implementation of that can be found here:
www.hikashop.com/forum/taxes/873285-fix-tax-import.html#190511
Please Log in or Create an account to join the conversation.
I installed it but don't know how to use it ?
I actived it and went in Hikashop's Option.
I clicked on the new button but I can only fill a name and some others but there isn't mention of any price or something ?
Please Log in or Create an account to join the conversation.
You can't just use it for what you want to do. You need to modify its code.
When you configure it via the new button of the System>Plugins menu, you'll get a screen with the options of the plugin and you'll be able to set the price that you want to be displayed on the cart in the checkout.
Please Log in or Create an account to join the conversation.
I saved it in $_SESSION and you said I could recover it everywhere but when I want to display it it doesn't work.
The plugin you gave me allow me to add the donation value to the total right ?
Please Log in or Create an account to join the conversation.
I didn't say that you could get the value from anywhere if you put it in the SESSION. I only said that you would be able to get it in the order creation email by doing that.
And no, the plugin global cart fee doesn't allow you to add the donation value to the total. What it does is it allows you to add a fixed value to the total of the cart. As I said, in order for it to do what you want, you'll have to modify its code.
Please Log in or Create an account to join the conversation.
I got it for the value. I used it but how can I display it too in the other mail ? I have to recover it in the notification of the command status how can I do it ?
I can't just put it in the database where is the final total ?
Ok i'll try to understand it and modify
Thank you !
Please Log in or Create an account to join the conversation.
For example if you add your data in a new column of that table that you call "my_data", you can use the tag below in the HTML version of the email and it will display your data in the email:
{VAR:order.my_data}
Please Log in or Create an account to join the conversation.
Can I do $data->order->my_data = 'my donation value'; ??
Please Log in or Create an account to join the conversation.
In which function of which file ?
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
So you need to do the save yourself:
Please Log in or Create an account to join the conversation.