Advertisement:

Author Topic: [SOLVED] How to solve the "zero" free price  (Read 3955 times)

Aficionado

  • Guest
Re: How to solve the "zero" free price
« Reply #15 on: September 15, 2017, 11:06:18 pm »
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

  • issues
  • Hero Member
  • *
  • Posts: 1652
  • "BE GRATEFUL TO THOSE THAT SUPPORTED YOU"
Re: How to solve the "zero" free price
« Reply #16 on: September 15, 2017, 11:11:27 pm »
@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 :)


marius-ciclistu

  • issues
  • Hero Member
  • *
  • Posts: 1652
  • "BE GRATEFUL TO THOSE THAT SUPPORTED YOU"
Re: How to solve the "zero" free price
« Reply #17 on: September 15, 2017, 11:23:45 pm »
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".

Aficionado

  • Guest
Re: How to solve the "zero" free price
« Reply #18 on: September 15, 2017, 11:29:20 pm »

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 ?


marius-ciclistu

  • issues
  • Hero Member
  • *
  • Posts: 1652
  • "BE GRATEFUL TO THOSE THAT SUPPORTED YOU"
Re: How to solve the "zero" free price
« Reply #19 on: September 15, 2017, 11:32:26 pm »
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.

Liath

  • issues
  • Hero Member
  • *
  • Posts: 1346
  • </html> the end is always near
Re: How to solve the "zero" free price
« Reply #20 on: September 16, 2017, 12:52:54 am »
another solution would be to show price only, if price is bigger than 0


for example
Code: [Select]
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
Code: [Select]

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
Code: [Select]
<?php echo cust_item_price(osc_item_price()); ?>
« Last Edit: September 16, 2017, 01:12:58 am by Liath »

Aficionado

  • Guest
Re: How to solve the "zero" free price
« Reply #21 on: September 16, 2017, 01:07:02 am »
another solution would be to show price only, if price is bigger than 0


for example
Code: [Select]
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.


Liath

  • issues
  • Hero Member
  • *
  • Posts: 1346
  • </html> the end is always near
Re: How to solve the "zero" free price
« Reply #22 on: September 16, 2017, 01:14:40 am »
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

« Last Edit: September 16, 2017, 01:25:42 am by Liath »

Aficionado

  • Guest
Re: How to solve the "zero" free price
« Reply #23 on: September 16, 2017, 02:31:50 am »
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.

Liath

  • issues
  • Hero Member
  • *
  • Posts: 1346
  • </html> the end is always near
Re: How to solve the "zero" free price
« Reply #24 on: September 16, 2017, 03:14:04 am »
so you need only to use something like this

if you want to show "0.00 €"
Code: [Select]
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
Code: [Select]
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
Code: [Select]
<?php echo osc_item_formatted_price(); ?>

Aficionado

  • Guest
Re: How to solve the "zero" free price
« Reply #25 on: September 16, 2017, 02:05:25 pm »
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)
« Last Edit: September 16, 2017, 02:07:30 pm by Aficionado »

Aficionado

  • Guest
Re: How to solve the "zero" free price
« Reply #26 on: September 18, 2017, 08:32:27 pm »
I used this suggestion:

Code: [Select]
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

Aficionado

  • Guest
Re: [SOLVED] How to solve the "zero" free price
« Reply #27 on: September 19, 2017, 09:38:06 pm »
Liath it seems an extra check must be done in

Code: [Select]
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.


marius-ciclistu

  • issues
  • Hero Member
  • *
  • Posts: 1652
  • "BE GRATEFUL TO THOSE THAT SUPPORTED YOU"
Re: [SOLVED] How to solve the "zero" free price
« Reply #28 on: September 19, 2017, 09:42:42 pm »
Liath it seems an extra check must be done in

Code: [Select]
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

Code: [Select]
osc_add_filter ('item_price_null', 'cust_item_price_zero');

Aficionado

  • Guest
Re: [SOLVED] How to solve the "zero" free price
« Reply #29 on: September 19, 2017, 11:57:22 pm »

Try removing this line

Code: [Select]
osc_add_filter ('item_price_null', 'cust_item_price_zero');

Nope. That totally removes the custom text.