How to configure a currency per Vendor for products and checkout

  • Posts: 128
  • Thank you received: 2
7 years 4 months ago #256031

-- HikaShop version -- : 2.6.4
-- HikaMarket version -- : 1.7.2
-- Joomla version -- : 3.6.4
-- PHP version -- : 5.6

Hi there,

I'm a bit confused with the currency options since I don't seem to be able to achieve what I'm after. I hope you can help me with it.

I use HikaMarket Multivendor and I want to be able to display prices and take payments in the currency of each Vendor.

So each Vendor defines a currency when they register and they will price all their products in this currency. Then all the payments to this Vendor need to be done in this currency.

That means, as an example:

- Vendor 1 uses Euros, all his products will be priced in Euros and all the payments to him should be in made in Euros.
- Vendor 2 uses USD, all his products will be priced in USD and all the payments to him should be in made in USD.
- Vendor 3 uses GBP, all his products will be priced in GBP and all the payments to him should be made in GBP.

So the first thing I have done is setting up the HikaMarket Option to allow only products from one vendor in the Cart, which is necessary to avoid mixing currencies.

A) The first question is, the product catalog of the e-Shop will have products from all the vendors, how do I achieve that products from Vendor 1 show the price in Euros, products form Vendor 2 in USD and products from Vendor 3 in GBP?

B ) Once the products are added to the Cart, the same thing. If the products are from vendor 1, ALL the prices in the Cart should be in Euros and only in Euros, including the product prices, the total price, the discount, etc. The same for the other Vendors in their own currencies.

C) I use MangoPay as payment plugin, so when the Cart contains Products from Vendor 1 the customer should be charged in Euros, if the products are from Vendor 2 the customer should be charged in USD, and so forth.

D) All the email notifications should quote the pricing and totals in the products/vendor currency.

I'd appreacite some guidance about how to achieve this.

Many thanks!

Last edit: 7 years 4 months ago by sabroso.

Please Log in or Create an account to join the conversation.

  • Posts: 25994
  • Thank you received: 4004
  • MODERATOR
7 years 4 months ago #256033

Hi,

There is no setting to do so in HikaMarket but it is possible to add that feature using a little custom plugin.

The first part would be to customize/configure HikaShop to display the prices in the original currency.
I don't know what you want to have for the final result about the price display but that part would be only related to HikaShop.
Your vendor will configure the product in their currency ; so you should have a consistent content.

About the cart and the currency ; the goal is to have a little custom plugin.
That plugin will load the customer cart and check if the cart have some products into.
If so, he will check the first product of the cart (because you have the vendor limitation) to know the current cart vendor.
By loading the vendor object, you will have the currency ; currency that you can put in the HikaShop session in order to force the currently used currency.
And that little plugin will do the "trick".

To unsure the compatibility with HikaShop 3 ; you will just have to plan few extra lines to change the cart currency if the current stored value is not the same.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 128
  • Thank you received: 2
7 years 4 months ago #256057

Hi Jerome,

Thanks for that.

So the display of pricing on the original currency you mean can be achieved simply by view overrides in HIkaShop, did I understand this correctly?

Regarding the plugin, what trigger do you recommend me? I can think of two or three but I'm not sure which one would be better

a) onBeforeCartUpdate(&$cartClass,&$cart,$product_id,$quantity,$add,$type,$resetCartWhenUpdate,$force,&$do)

The good thing here is that I have access to the cart object, so I can update it, and also to the product ID, so I can query the Vendor and the Vendor's Currency. But this would be called every time a product is added to the cart, right? But what if the product added is from a different Vendor and with a different currency? Will the single Vendor check stop this before my plugin is executed? Or would it be better to do this onAfterCartUpdate ?

b) onAfterCartProductsLoad(&$cart)

The good thing here is that it is only executed once the customer goes to the checkout, correct? Is this executed before the customer sees the product list in the cart? And, considering it is AFTER the products are loaded, is it the right moment to change the cart currency? I cannot see a trigger for onBeforeCartProductsLoad in your documentation?

c) onBeforeCheckoutStep($controllerName, &$go_back, $original_go_back, &$controller)

Here I could execute my plugin before the first checkout step, so when the customer goes to check out he sees the currency I want. BUT I have no access to the cart?

Many thanks for your advice!

Please Log in or Create an account to join the conversation.

  • Posts: 25994
  • Thank you received: 4004
  • MODERATOR
7 years 4 months ago #256077

Hi,

The trigger "onAfterCartProductsLoad" would be the most appropriate trigger for such task.
I also recommend to use the trigger "onBeforeOrderCreate" to be sure that it won't be possible to have a different currency on the order creation.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 128
  • Thank you received: 2
7 years 4 months ago #256117

Hi Jerome,

Thanks for that.

Please correct me if I misunderstood you, but I think this is what you suggested, right?

function onAfterCartProductsLoad(&$cart)
{
	if (empty($cart->products))
			return;

	$config = hikashop_config();
	$app = JFactory::getApplication();

	$main_currency = (int)$config->get('main_currency', 1);
	$currency_id = (int)$app->getUserState(HIKASHOP_COMPONENT.'.currency_id', $main_currency);

	$first_product = reset($cart->products);

	echo '(old session currency: '.$session_currency.') ';
	echo 'session id: '.$cart->products[0]->session_id;
	echo ' || ';
	echo 'vendor id: '.$first_product ->product_vendor_id;
	echo ' || ';

	$vendor_currency = $this->getVendorCurrency($first_product ->product_vendor_id);

	echo 'vendor currency: '.$vendor_currency;
	echo ' || ';

	$app->setUserState(HIKASHOP_COMPONENT.'.currency_id', $vendor_currency);
//	$app->setUserState( HIKASHOP_COMPONENT.'.payment_data.payment_params.payment_currency', $vendor_currency );
//	$new_session_currency = $app->getUserState( HIKASHOP_COMPONENT.'.payment_data.payment_params.payment_currency', 0, 'int' );
//
//	echo '(new session currency: '.$new_session_currency.') ';
//	echo '<br />';	
}

My test case is as follows:
Hikashop main currency: USD (currency id:2)
The product "Milonga 1" set up in Euros (currency id:1) and owned by Vendor with vendor ID = 2
Vendor with vendor ID = 2 has currency in Euros (currency id:1)

Then when I add the product "Milonga 1" to the cart and I'm redirected to the checkout I see as per the attachment.

As you can see the plugin executes two times.

At the begining of the plugin the session currency has no value or value 2 (USD), and at the end of the plugin I set it to the Vendor currency Euros (id:1).

But the display of pricing is still showing as if USD is the cart currency, including the total. So something looks like it is not working.

Any idea? Am I setting the right currency session setting? Is there anything else that could be changing the session currency back to the main shop currency after my plugin?

Attachments:
Last edit: 7 years 4 months ago by Jerome. Reason: Modifications in the code

Please Log in or Create an account to join the conversation.

  • Posts: 25994
  • Thank you received: 4004
  • MODERATOR
7 years 4 months ago #256135

Hi,

I made some modifications in your code.

To change the currency, the best is to change the HikaShop currency so the all website will use it.
Each time a plugin (or any code) require the currency, it uses the "hikashop_getCurrency()" function.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 128
  • Thank you received: 2
7 years 4 months ago #256333

I tested your modifications and it is working great.

Thanks a lot for your help, much appreciated!

Please Log in or Create an account to join the conversation.

  • Posts: 99
  • Thank you received: 0
5 years 5 months ago #299358

Hello,

This subject is a bit old, any update please?

Pretty much the same situation,
In edit vendor details, I can switch the currency "datavendorvendor_currency_id"

But when I try to add a product, the currency has not change, still the store (previous).
Same when the product is published "hikashop_product_price hikashop_product_price_0"

Can you help please ?

Best,

Please Log in or Create an account to join the conversation.

  • Posts: 25994
  • Thank you received: 4004
  • MODERATOR
5 years 5 months ago #299410

Hello,

The currency setting that you can found in the vendor profile is the preferred currency for its payments.
That feature was not added in our TODO nor implemented into HikaShop since we did not see the need for the majority of the customer and it could generated some issues with HikaShop features (like the currency switcher or the geolocation one).

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 99
  • Thank you received: 0
5 years 5 months ago #299448

Hello,

If I want an international website with vendors in different currencies, I need different websites ? So in this case if I want $US and $CAD, I need one website for the US and one for Canada ?

Regards,

Please Log in or Create an account to join the conversation.

  • Posts: 25994
  • Thank you received: 4004
  • MODERATOR
5 years 5 months ago #299495

Hello,

HikaShop is multi-currency. You can have a currency switcher and your vendors can set-up their prices in their currency, HikaShop can display the original price and the converted price.

Afterwards, if you do want to split your store in two for two currencies ; you can organise your vendors in two "categories".
But depending how you configured your store, you can authorize products of several vendors in the same time, which would mean that you can have products in two different currencies. It's a thing that HikaShop handle perfectly since it can convert the prices.

It just require to understand what you want to do exactly.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 99
  • Thank you received: 0
5 years 5 months ago #299520

Hello,

You said
"The currency setting that you can found in the vendor profile is the preferred currency for its payments."

Is it possible for the vendor to decide the currency of his products? Or is it automatic like if he's in Europe :€, US :$...

I don't really want the user to be able to switch currency on the website, he will see the product in the currency the vendor decided. At the end if he really want to buy a product € with his card $, well he will probably pay fees through his bank... I Hope it makes sense,
Regards,

Please Log in or Create an account to join the conversation.

  • Posts: 25994
  • Thank you received: 4004
  • MODERATOR
5 years 5 months ago #299541

Hello,

When the vendor create a product, the currency selected by default for the new prices is the default currency of the store.
Afterwards, you can use product templates if you do want to pre-fill some fields and for example, pre-set some prices with another currency.

Afterwards the vendors can use all currencies which are published and available in your website. Just like you do in the backend.

The handle of currencies is something related to HikaShop and not HikaMarket.
You can have products with different currencies in HikaShop and all stuff related to the display and processing is made by HikaShop.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 99
  • Thank you received: 0
5 years 5 months ago #299566

Hello,

I would like to share with you 3 small screenshots, please follow

This message contains confidential information


1: I create a Vendor and I set Currency,
2: I can edit the profile and the currency later,
3: On the last image, when I add a product, the currency is not the one I selected (I understand that this currency is the STORE currency for when the vendor buys from another vendor ... Useless in this situation and for all my store, because the price will be displayed only according to the vendor selection).

Some options:
  • Hikashop > System > Currencies : 3 currencies published and displayed.
  • In Hikamarket, Market Options, Ask for currency : YES
  • TAXES AND FEES OPTIONS : 3 currencies as well.

Please, how can the vendor choose a currency for his profile (for all his products) among the 3 published currencies?

Regards,

Last edit: 5 years 5 months ago by ChristopheMG. Reason: typo

Please Log in or Create an account to join the conversation.

  • Posts: 25994
  • Thank you received: 4004
  • MODERATOR
5 years 5 months ago #299568

Hello,

You did not give the ACL "product / edit / price / currency" to your vendor.
As explained, the currency setting in the vendor profile is regarding the preferred currency for its payments (when you pay him in the backend)

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.
The following user(s) said Thank You: ChristopheMG

Please Log in or Create an account to join the conversation.

  • Posts: 99
  • Thank you received: 0
5 years 5 months ago #299760

Hello,

Thank you! Almost done.
I use the switcher module and geolocalization, this way if a vendor is in France, the buyer in France should see the product in EUROS only.
If another vendor is in the US, the buyer same will see the product in $.

The only thing I would like to improve is a way for the vendor to select the same currency for all products (his products), probably from his profile.
Instead of selecting the currency on each product page creation...Is it possible?

Last point, I use Paypal, Parallel payment mode, Sender fee mode.The vendor receives the money directly and the website too %.
Since some vendors will sell in euros, others in dollars ... In the end, on the paypal account of the site, I should see euros and dollars.
Just please tell me if you just read something that sounds wrong.

Thank you,

Last edit: 5 years 5 months ago by ChristopheMG. Reason: typo

Please Log in or Create an account to join the conversation.

  • Posts: 25994
  • Thank you received: 4004
  • MODERATOR
5 years 4 months ago #299818

Hello,

Best would be to use a view override.
I don't know which kind of price edition you have (because it changes depending the ACL) ; but the idea is to set-up a value when the vendor is creating a price.
For example in the view "form_price_entry", you will find the line

echo $this->currencyType->display($form_key.'['.$this->price_num.'][price_currency_id]', @$this->price->price_currency_id, '','hikamarket_' . $form_key . '_currency_edit');
And the idea is to put a value into "price_currency_id" if that variable is empty.
Like
if(empty($this->price->price_currency_id)) {
	$vendor = hikamarket::loadVendor(true);
	$this->price->price_currency_id = (int)$vendor->vendor_currency_id;
}

The customer will pay in the currency he has selected. The vendor will see the order with that same currency.
In case of payment is not with the same currency than the vendor ; If the vendor authorize Paypal to perform the conversion, he will receive the money in his currency and Paypal will do the conversion for him automatically. Otherwise, he would have to do manually an action and it could delay the order confirmation.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.
The following user(s) said Thank You: ChristopheMG

Please Log in or Create an account to join the conversation.

  • Posts: 99
  • Thank you received: 0
5 years 4 months ago #299851

Hello,

This is the logic yes, to copy the vendor currency ($vendor->vendor_currency_id) to the product currency (this->price->price_currency_id).
I would rather say "erase" instead of copy. And to not display the product currency on product page, this way product currency = vendor currency and nothing more.

I tried the code in "form_price_entry", not working, can you please precise ?

Thank you for your help.

Please Log in or Create an account to join the conversation.

  • Posts: 25994
  • Thank you received: 4004
  • MODERATOR
5 years 4 months ago #299859

Hello,

As I wrote, the view depends on your ACL settings.

I don't know which kind of price edition you have (because it changes depending the ACL)


Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 99
  • Thank you received: 0
5 years 4 months ago #299890

Hello,

Well now both are published:
Vendor > Edit > Currency is published
Product > Edit > Price > Currency is published.

The best would be to publish only the first one, and to process in the code, product currency = vendor currency.
This way again, all products currency = vendor currency.

Please let me know, I'm pretty sure your code is almost the solution.
Thank you,

Please Log in or Create an account to join the conversation.

Moderators: Obsidev
Time to create page: 0.104 seconds
Powered by Kunena Forum