Osclass forums
Support forums => General help => 3.7.x => Topic started by: Aficionado on September 15, 2017, 06:35:32 pm
-
Hi,
One of the major problems i have is that most posters of ads, give zero as price and then Free is displayed. Apparently they don't mean Free, they just don't want to give a price.
Any ideas how to solve or improve this ?
Thanks
-
You could recplace the "free" word in language files with "ask for price".
-
You could recplace the "free" word in language files with "ask for price".
Tried that, BUT the price field is also shows at Items and the label was totally wrong to display.
Maybe i could inject a message in there, apart from the language file. Next to the Price field or above.
-
Or you could prevent the input of 0 in the price's field to begin with.
-
Or you could prevent the input of 0 in the price's field to begin with.
Sure, if i knew how....
or even better if zero, then a "Are you sure it is Free" dialogue. Still all those required extra coding, and i don't want to do that.
-
If I would knew I would have wrote the solution in the previous post :D
But let's see:
oc-includes/osclass/helpers/hItems.php:
/**
* Formats the price using the appropiate currency.
*
* @param float $price
* @return string
*/
function osc_format_price($price, $symbol = null) {
if ($price === null) return osc_apply_filter ('item_price_null', __('Check with seller') );
if ($price == 0) return osc_apply_filter ('item_price_zero', __('Free') );
if($symbol==null) { $symbol = osc_item_currency_symbol(); }
$price = $price/1000000;
$currencyFormat = osc_locale_currency_format();
$currencyFormat = str_replace('{NUMBER}', number_format($price, osc_locale_num_dec(), osc_locale_dec_point(), osc_locale_thousands_sep()), $currencyFormat);
$currencyFormat = str_replace('{CURRENCY}', $symbol, $currencyFormat);
return osc_apply_filter('item_price', $currencyFormat );
}
replace with
/**
* Formats the price using the appropiate currency.
*
* @param float $price
* @return string
*/
function osc_format_price($price, $symbol = null) {
if ($price === null || $price == 0) return osc_apply_filter ('item_price_null', __('Check with seller') );
/* if ($price == 0) return osc_apply_filter ('item_price_zero', __('Free') );*/
if($symbol==null) { $symbol = osc_item_currency_symbol(); }
$price = $price/1000000;
$currencyFormat = osc_locale_currency_format();
$currencyFormat = str_replace('{NUMBER}', number_format($price, osc_locale_num_dec(), osc_locale_dec_point(), osc_locale_thousands_sep()), $currencyFormat);
$currencyFormat = str_replace('{CURRENCY}', $symbol, $currencyFormat);
return osc_apply_filter('item_price', $currencyFormat );
}
I'll make this to my website as well. Thank you.
-
This is the change ?
/* if ($price == 0) return osc_apply_filter ('item_price_zero', __('Free') );*/
-
if ($price === null || $price == 0) return osc_apply_filter ('item_price_null', __('Check with seller') );
/* if ($price == 0) return osc_apply_filter ('item_price_zero', __('Free') );*/
-
if ($price === null || $price == 0) return osc_apply_filter ('item_price_null', __('Check with seller') );
/* if ($price == 0) return osc_apply_filter ('item_price_zero', __('Free') );*/
right. got it. thanks i will change it during the weekend.
8)
-
This forum is great:)) I'm learning alot from it even if sometimes I teach my self with the help of others that are just asking:)) (But also I learned alot from others that posted solutions)
So a big THANK YOU to all !
-
This forum is great:)) I'm learning alot from it even if sometimes I teach my self with the help of others that are just asking:)) (But also I learned alot from others that posted solutions)
So a big THANK YOU to all !
Nice also to see people like you, that offer help the community of Osclass.
-
I received help so I give help when and if I can.... I liked the idea of the man behind linux in comparison with Bill G.
-
If i understand right, you want to change the free text or make some changes on that level free?
You don't have to change the core files, you have some filters in formatted price that you can use.
For example for changing the free tag with the price and symbol:
this in your theme functions.php file
function new_filter_for_free_price(){
return osc_item_price().' '. osc_item_currency_symbol();
}
osc_add_filter ('item_price_zero', 'new_filter_for_free_price');
Of course that you can play more with this
function new_filter_for_free_price(){
return __('your text');
}
In this way you don't have to make this changes every time you update osclass.
You have more filters there that you can use in the same way.
osc_add_filter ('item_price_null', 'your function' ); - for check with seller
osc_add_filter('item_price', 'your function' ); - for final price
-
Calin,
This is nice in case the user didn't change osclass files.
But as I saw, there are many that made changes ( like me) , so they can choose the best solution for them from these 2.
PS. While updating, the theme is not updated as well?
-
@marius-ciclistu I think the best way to make the changes it avoid to change osclass core or theme files. You can create a plugin in just a few steps and include all your changes in the plugin, so in this way your core files and theme files will not be changed and you will not have to do this changes on each update.
-
If i understand right, you want to change the free text or make some changes on that level free?
Most people write zero (without knowing that 0 is free for Osclass). That is wrong from the users side and also poor decision for Osclass code.
-
@marius-ciclistu I think the best way to make the changes it avoid to change osclass core or theme files. You can create a plugin in just a few steps and include all your changes in the plugin, so in this way your core files and theme files will not be changed and you will not have to do this changes on each update.
Between me and you, I 'hate' plugins because they generate issues/conflicts. I prefer clean strong core code, that is why the only plugin I use is google analitics for inserting the tracking code (that is useless when blocked by browsers that have the DO NOT TACK option checked, anyway) - But, I know, this is not an approach good for business :)
-
If i understand right, you want to change the free text or make some changes on that level free?
Most people write zero (without knowing that 0 is free for Osclass). That is wrong from the users side and also poor decision for Osclass code.
Opencart displays the 0 price as it is so not only osclass has this "issue".
-
Opencart displays the 0 price as it is so not only osclass has this "issue".
I'm not familiar with Opencart. Does OpenCart interprets zero as FREE ?
-
It just displays it as 0 and you can put it into the cart and finish your order, so I would say yes. I resolved that by replacing the "add to cart" button with a link to contact when the price is 0 and hiding the price in most of the opencarts I configured.
-
another solution would be to show price only, if price is bigger than 0
for example
if (is_numeric(osc_item_price()) && osc_item_price() > 0) {
echo osc_item_formated_price();
}
this could be done by modifying your template
edit:
or just make your own function in your theme functions.php
function cust_item_price($price) {
$price = $price/1000000;
$symbol = osc_item_currency_symbol();
$currencyFormat = osc_locale_currency_format();
$currencyFormat = str_replace('{NUMBER}', number_format($price, osc_locale_num_dec(), osc_locale_dec_point(), osc_locale_thousands_sep()), $currencyFormat);
$currencyFormat = str_replace('{CURRENCY}', $symbol, $currencyFormat);
if ($price > 0) {
return $currencyFormat;
} else {
return "No Price";
}
}
and use this to show the price
<?php echo cust_item_price(osc_item_price()); ?>
-
another solution would be to show price only, if price is bigger than 0
for example
if (is_numeric(osc_item_price()) && osc_item_price() > 0) {
echo osc_item_formated_price();
}
this could be done by modifying your template
This is a nice idea, but harder to do, since it needs to modify the items.php and also some other file dealing with the latest ads in front page.
-
i've edited my post..
This is a nice idea, but harder to do, since it needs to modify the items.php and also some other file dealing with the latest ads in front page.
isnt it better to modify the theme instead of the core?
edit:
now i see the solution from calinbehtuk ;D
-
i've edited my post..
This is a nice idea, but harder to do, since it needs to modify the items.php and also some other file dealing with the latest ads in front page.
isnt it better to modify the theme instead of the core?
edit:
now i see the solution from calinbehtuk ;D
yeah. those filters are extremely powerfull if you know how to use them.
-
so you need only to use something like this
if you want to show "0.00 €"
function cust_item_price_zero(){
$price = '0';
$symbol = osc_item_currency_symbol();
$currencyFormat = osc_locale_currency_format();
$currencyFormat = str_replace('{NUMBER}', number_format($price, osc_locale_num_dec(), osc_locale_dec_point(), osc_locale_thousands_sep()), $currencyFormat);
$currencyFormat = str_replace('{CURRENCY}', $symbol, $currencyFormat);
return $currencyFormat;
}
osc_add_filter ('item_price_zero', 'cust_item_price_zero');
osc_add_filter ('item_price_null', 'cust_item_price_zero');
if you want to show your own text
function cust_item_price_zero(){
return __('Your own text');
}
osc_add_filter ('item_price_zero', 'cust_item_price_zero');
osc_add_filter ('item_price_null', 'cust_item_price_zero');
then everywhere you are using following function, the changed price format appear
<?php echo osc_item_formatted_price(); ?>
-
Thank you all for the suggestions. I will be able to test all those in Monday.
This weekend i can't touch anything, since we are moving to a new server system and who knows what that will bring.
(For a couple of years now we've been using a Nimble CS500 SSD Accelerated Storage Area Network. We are moving to a StorPool Highly Available, Distributed, Self-Healing SSD Storage Area Network)
8)
-
I used this suggestion:
function cust_item_price_zero(){
return __('Your own text');
}
osc_add_filter ('item_price_zero', 'cust_item_price_zero');
osc_add_filter ('item_price_null', 'cust_item_price_zero');
and works just great.
Many thanks
-
Liath it seems an extra check must be done in
function cust_item_price_zero(){
return __('Your own text');
}
osc_add_filter ('item_price_zero', 'cust_item_price_zero');
osc_add_filter ('item_price_null', 'cust_item_price_zero');
since the "Enable / Disable the price field" is not taken into consideration.
-
Liath it seems an extra check must be done in
function cust_item_price_zero(){
return __('Your own text');
}
osc_add_filter ('item_price_zero', 'cust_item_price_zero');
osc_add_filter ('item_price_null', 'cust_item_price_zero');
since the "Enable / Disable the price field" is not taken into consideration.
Try removing this line
osc_add_filter ('item_price_null', 'cust_item_price_zero');
-
Try removing this line
osc_add_filter ('item_price_null', 'cust_item_price_zero');
Nope. That totally removes the custom text.
-
In which case? Price 0 or price null(=price disabled) ?
Normally it should remove de custom text only while the price is null / disabled.
The other hook should work for price==0.
-
In which case? Price 0 or price null(=price disabled) ?
Normally it should remove de custom text only while the price is null / disabled.
The other hook should work for price==0.
When the price is disabled in that category, when the second hook is removed, i get the Osclass languages text.
-
Actually maybe i'm doing something wrong. Just hold this for a while pls.
-
function cust_item_price_zero(){
return __('Your own text');
}
if (osc_price_enabled_at_items()) {
osc_add_filter ('item_price_zero', 'cust_item_price_zero');
osc_add_filter ('item_price_null', 'cust_item_price_zero');
}
maybe this is helpful
-
In which case? Price 0 or price null(=price disabled) ?
Normally it should remove de custom text only while the price is null / disabled.
The other hook should work for price==0.
When the price is disabled in that category, when the second hook is removed, i get the Osclass languages text.
Exactly my point.This is how it should work. In this case if price is disabled you see 'Check with seller' because in that case price is null.
If the price is 0 you see 'your custom text'.
Doesn't this resolve your issue about price disabled/enabled that you mentioned?
-
The way the price is used in Osclass is by design, a choice once made and a fundamental one.
Your users seem to enter a 0 price as where they mean 'Ask me' so the first thing you need if not already in your theme is the price explanation ie. 0 = FREE / Empty = ASK and if your users are blind or just ignorant what are you going to fix? 8)
In case you want a different price approach it is best to make these in the theme & functions.php ie. the Liath solution is doable however the category pricing is still being handled in core JS according to price design.
Here's another possible theme solution trying to help your users selecting a price:
-- * Price * ----------------------------------------------
| O Free O Ask O [ 0,00 ] [ currency dropdown ] |
-----------------------------------------------------------
OR
-- * Price * -----------------------------
| O Free |
| O Ask |
| O [ 0,00 ] [ currency dropdown ] |
------------------------------------------
OR
-- * Price * ------------
| [ price dropdown ] |
-------------------------
With the options; "Free", "Ask Seller", "Enter Price" so when the latter is selected the price input field and currency selector are displayed.
"Ask" can be set to default so it would save many of your users the extra input and making it vast impossible to post using incorrect price. There's no need to change the price logic with regard to the price input design is there?
"What" is being displayed based on user selection is handled in PO/MO files, no need to add filters really.
If you want to 'swap' '' and 0 text display you could also simply change this in PO/MO ie. the text "Ask seller" becomes "Free" and "Free" becomes "Ask seller" and ofcourse you would also have to change the price explanation for this and any related search text. This way labels are kept consistent by Osclass and users can enter a zero and see the text "Ask Seller" insetad of "Free". It is all a matter of how you want your users to "SELECT" the correct price.
You could recplace the "free" word in language files with "ask for price".
Tried that, BUT the price field is also shows at Items and the label was totally wrong to display.
Maybe i could inject a message in there, apart from the language file. Next to the Price field or above.