Перейти к содержимому


Фотография
- - - - -

JBZoo Price


  • Закрытая тема Тема закрыта
Сообщений в теме: 22

#11 Kess

Kess

Отправлено 10 November 2013 - 10:17

Look at the

media/zoo/applications/jbuniversal/config/jbcurrency.xml

 

You can add new currency there using others as an example. Also you can set format to the one that you need.

 

Also it would be better to also define this new currency in the language file (media/zoo/applications/jbuniversal/language). There is a section with currencies there, each variable starts with "JBZOO_JBCURRENCY_" followed by the currency name from that xml file.

 

If you want to display just simple price without any currency switcher then I think it should work fine.


Сообщение отредактировал Kess: 10 November 2013 - 10:19

  • 0

#12 P.K

P.K

Отправлено 10 November 2013 - 12:27

Hi

1)What would be the method if i want to need the currency switcher? The will i have to change the values of the existing currencies?

 

 

2) The problem right now is that i have my price as 32200.00 so the by using format 3 i get Rs.3220000.00 What could be done in this case?

 

3) And another issue is the price filter, the price displayed there is in format 32 200. Now what could be the solution

 

4) Also the INR has the format 1,00,00,000.00 i.e the first comma is after thousand and then after every hundred. So what do you suggest

 

 

Thanks


  • 0

#13 Kess

Kess

Отправлено 10 November 2013 - 14:01

1. I've tried it and it seems to work fine. You'll just need to also modify CSS to make a new flag icon for this currency. And in the string that defines this currency in xml file you should define it's relation to euro so the calculation will work properly.

 

2. In the line that defines the currency you can set different prefixes and postfixes to achieve desired format. So, for example, if you want "Rs." to be at the end, you should leave prefix empty and type " Rs." in the postfix.

 

3. I guess this is how jQuery UI slider works with numbers by default. I was unable to find a quick solution to this, I think you'll have to modify its script to set your culture type.

 

4. In the file 

 

media/zoo/applications/jbuniversal/framework/helpers/jbmoney.php

 

find the function "toFormat". There is a line in it:

$formated = number_format($value, $format['decimals'], $format['dec_point'], $format['thousands_sep']);

You'll need to add a condition here, so replace this line with this:

if ($code == "TEST") {
    setlocale(LC_MONETARY, 'en_IN');
    $formated = money_format('%!i', $value);
}
else {
    $formated = number_format($value, $format['decimals'], $format['dec_point'], $format['thousands_sep']);
}

Notice the "TEST" at the start. You should replace it with your currency name from the jbcurrency.xml, in the uppercase.

 

That's how it works on the test website:

 

k4c_200x0.png


  • 0

#14 P.K

P.K

Отправлено 10 November 2013 - 16:13

Hi
The problem that now remains is that it is showing price 32200 as 32,20,000.00 which is 100 times greater. And i am unable to remove the decimal even after changing the format in jbcurrency.xml

What needs to be done?

 

thanks


Problem 2 is that the filter is not updating itself with the price values. :(

 

What needs to be done then to solve this?


  • 0

#15 Kess

Kess

Отправлено 10 November 2013 - 17:14

1. I think you made a mistake somewhere. Here is how it's working on a test website:

 

price in the item editing:

7xx_200x0.png

 

price on the website:

13h_200x0.png

 

So as you can see it's not 100 times greater. Please, paste here the line from xml file that you added and also a screenshot of some product both from back-end and front-end.

 

To remove decimals, change

$formated = money_format('%!i', $value);

to

$formated = money_format('%!.0i', $value);

2. As I told you from the start, there might be a problem with a filter if we'll add prices on-the-fly, not from the database.


  • 0

#16 P.K

P.K

Отправлено 10 November 2013 - 18:24

Hi

The last modification solved the problem but if filter is not working then everything becomes useless. I was thinking of two methods by which we could make the filter work

1) If we could just take the price which is taken on the fly and then store it to the price field of the jbzoo item table? 

 

2) Or the other thing that can be done is that i could store the value of prices in the jbzoo price table that can be done by just copying data from my script to the jbzoo price table. But you need to tell me a few things

    a) The items in my script are identified by alias so in the jbzoo table containing price the price field should be identified by alias

    b) which table and field contains the prices. Is it xyz_zoo_jbzoo_sku??

    c) My prices from the script keep on changing so what would be the method for such

 

Still i would prefer the first method (if possible) as it has half work already done

 

thanks


Сообщение отредактировал P.K: 10 November 2013 - 18:28

  • 0

#17 SmetDenis

SmetDenis

Отправлено 12 November 2013 - 09:07

Hello.

Filter gets values from special search index tables - #__zoo_jbzoo_index and #__zoo_jbzoo_sku
otherwise JBZoo can't execute searching SQL query.

Tables update automatically by system events such as create, update, remove and import items.
You will see it on \media\zoo\applications\jbuniversal\framework\events\jbevent.item.php saved(), deleted()

now I see these solutions:
1. On each update of price value call functions (to update search index)

JBModelSku::model()->updateItemSku($item); // for __zoo_jbzoo_sku
JBModelSearchindex::model()->updateByItem($item); // __zoo_jbzoo_index 

But if you update a lot of items at one time - be careful, it may take a lot of time to execute and use a lot of server memory.
(~ more then 32MB for 100 items)

2. After each price updates - do filter reindex . It's not convenient...

3. You may update index tables by cron script.
It's difficult, but works very quickly, then update each item.
You can find items data by element_id, or item_id column.
In this case PHP script you must do it yourself.


Сообщение отредактировал Kess: 12 November 2013 - 09:43

  • 0
JBZoo v4.0 и новый чудный мир Open Source GPL
Отключайте проверку лицензий как можно скорее!



— Есть два типа людей: Кто еще не делает бекапы и кто уже делает бекапы.


#18 P.K

P.K

Отправлено 13 November 2013 - 13:54

Hi Denis

 

Thanks for your prompt reply. 

First, I wished to inquire why is the update required for  __zoo_jbzoo_index and which field is required to modify. 

 

What i am thinking to do is-

When the price changes in my script then the jbzoo price field would be updated. This means that i have the  $row["name"] and $row["Price"] which have the name and price of product respectively. Now i just need make a sql query to update the __zoo_jbzoo_sku table with the prices. Please guide in that.

If there is need then i could also have the $row["id"] and $row["Price"] where id is same as that of the jbzoo item_id.

Whenever the price changes the table would be updated using unbuffered sql query. 

 

thanks


  • 0

#19 SmetDenis

SmetDenis

Отправлено 13 November 2013 - 15:52

Hi,
 
Sorry, but I don't understand you.
 
What is main problem? You can't write SQL query?
Are you look the structure of  #__zoo_jbzoo_sku table? I think it's very simple.
 
SQL example for table update
 
<?php
$sql = 'UPDATE `#__zoo_jbzoo_sku` SET `price`=' . $row["Price"] . ', `total`=' . $row["Price"] . ' WHERE `id`=' . $row["id"];
 
Table #__zoo_jbzoo_index need for searching other elements.
It is not necessary to update.
  • 0
JBZoo v4.0 и новый чудный мир Open Source GPL
Отключайте проверку лицензий как можно скорее!



— Есть два типа людей: Кто еще не делает бекапы и кто уже делает бекапы.


#20 P.K

P.K

Отправлено 15 November 2013 - 07:38

Hi

I have been able to get the price in the base price of the jbzoo cart. But i need to do database reindex after every price change. So is there any way to avoid this or any way to automate this because my price changes are quite frequent?

thanks


  • 0




Click to return to top of page in style!