Jump to content
Sign in to follow this  
minglou

EZ new fields v1.0

Recommended Posts

can someone tell us if the last version works also with ms1 ?


MS2

Share this post


Link to post
Share on other sites

This contrib works great...EXCEPT the savings % calculation doesn't work for prices greater than $999.99...so any product in the thousands will show a savings of 0%

 

you can see it working and not working at my site: http://www.lildevilmotorsports.com

 

If anyone knows how to fix it to properly display the savings % for products in the thousands, please let me know!!!

 

8)

Share this post


Link to post
Share on other sites

To the substr lines, e.g.

$no_savings = substr(($currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id']))), 1);

add a preg_replace to get rid of the commas before converting to floats, e.g.

$no_savings = preg_replace("/,/", "", substr(($currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id']))), 1));

No testing has been done on this. Use at your own risk.

 

It might make sense to do an sscanf instead of the preg_replace/substr pair, but I would want to try it before recommending any actual code. I also wonder if the currencies class might not have a numeric return that would work better than the string returned by display_price.

 

Good luck,

Matt

Share this post


Link to post
Share on other sites
To the substr lines, e.g.
$no_savings = substr(($currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id']))), 1);

add a preg_replace to get rid of the commas before converting to floats, e.g.

$no_savings = preg_replace("/,/", "", substr(($currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id']))), 1));

No testing has been done on this.  Use at your own risk.

 

It might make sense to do an sscanf instead of the preg_replace/substr pair, but I would want to try it before recommending any actual code.  I also wonder if the currencies class might not have a numeric return that would work better than the string returned by display_price.

 

Good luck,

Matt

 

Very Nice! Works like a charm!

 

Here is the result: http://www.lildevilmotorsports.com/catalog...products_id=205

 

Now if I can only get the comma added to the display of the retail price I am in business!

 

Thanks Again!

Share this post


Link to post
Share on other sites
Now if I can only get the comma added to the display of the retail price I am in business!
Try number_format. It will probably end up looking something like:
echo number_format($list_price, 2);

Hth,

Matt

 

correct again! 8)

 

for those of you following this thread, this is what the complete line will look like to properly display the comma if you have products that cost thousands like I do:

<?php echo number_format($product_info['products_retail_price'], 2); ?>

Share this post


Link to post
Share on other sites

Anybody else experiencing a PHP Warning "Division by zero..." with this great contrib?

 

All my products have a retail price and a cost....

 

I think it might be the way the arithmetic is written....

 

8)

Share this post


Link to post
Share on other sites
Anybody else experiencing a PHP Warning "Division by zero..." with this great contrib?

 

All my products have a retail price and a cost....

 

I think it might be the way the arithmetic is written....

 

8)

 

Just to add another tidbit since I can't edit my own post. this warning does not seem to appear on the screen. it get written to the error_log file in your catalog root.

 

8)

Share this post


Link to post
Share on other sites

I just installed this contrib on a November snapshot of osCommerce for a client and received the "Division by Zero" error when viewing a Product on the PRODUCT_INFO.PHP page. I believe this error occurs because the contribution is written for MS1 and MS2 and you are trying to install it on a pre-MS1 snapshot.

 

If you are also getting a "Division by Zero" error with this contrib, I just figured out the cause of this error and how to fix it. In the PRODUCT_INFO.PHP file, look for the following lines of code...

      $list_price = substr(($currencies->display_price($product_info['products_retail_price'], tep_get_tax_rate($product_info['products_tax_class_id']))),1); 

     $list_price =$list_price + 0.0;

     $our_price = substr(($currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id']))),1);

Change these lines of code to look like this...

      $list_price = substr(($currencies->display_price($product_info_values['products_retail_price'], tep_get_tax_rate($product_info_values['products_tax_class_id']))),1); 

     $list_price =$list_price + 0.0;

     $our_price = substr(($currencies->display_price($product_info_values['products_price'], tep_get_tax_rate($product_info_values['products_tax_class_id']))),1);

Basically, make sure that product_info is changed to product_info_values.

 

Hope this helps others!

 

Have a great day.

 

-R


"Courage is not the absence of fear, but the awareness of fear and the ability to get past it."

 

It's difficult to diagnose an issue when the patient says, "I have this pain right here Doc, what do you think it is?"

Share this post


Link to post
Share on other sites
I just installed this contrib on a November snapshot of osCommerce for a client and received the "Division by Zero" error when viewing a Product on the PRODUCT_INFO.PHP page. I believe this error occurs because the contribution is written for MS1 and MS2 and you are trying to install it on a pre-MS1 snapshot.  

 

If you are also getting a "Division by Zero" error with this contrib, I just figured out the cause of this error and how to fix it. In the PRODUCT_INFO.PHP file, look for the following lines of code...

      $list_price = substr(($currencies->display_price($product_info['products_retail_price'], tep_get_tax_rate($product_info['products_tax_class_id']))),1); 

     $list_price =$list_price + 0.0;

     $our_price = substr(($currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id']))),1);

Change these lines of code to look like this...

      $list_price = substr(($currencies->display_price($product_info_values['products_retail_price'], tep_get_tax_rate($product_info_values['products_tax_class_id']))),1); 

     $list_price =$list_price + 0.0;

     $our_price = substr(($currencies->display_price($product_info_values['products_price'], tep_get_tax_rate($product_info_values['products_tax_class_id']))),1);

Basically, make sure that product_info is changed to product_info_values.

 

Hope this helps others!

 

Have a great day.

 

-R

 

I will give it a shot but I am on MS2 and I do not get this error for every product viewed. Since I have so many products, I can't figure out which ones are trigerring it.

 

Time to test this...

Share this post


Link to post
Share on other sites

The fix that I described is for pre-MS1 snapshots. If you are using MS2, I dont think this fix would work... BUT... It could work the other way...

 

In PRODUCT_INFO.PHP, do you have code that references product_info_values? If so, try changing it to product_info and see if that helps.

 

For example...

 

<?php echo $product_info['products_price']; ?>

 

versus....

 

<?php echo $product_info_values['products_price']; ?>

 

Who knows, its worth a try. Do you have a link to see the error on one of your pages that I can see the error? I would be interested to see where the error is on the page. That will help to narrow down what piece of code is having the issue.

 

Let me know.

 

-R


"Courage is not the absence of fear, but the awareness of fear and the ability to get past it."

 

It's difficult to diagnose an issue when the patient says, "I have this pain right here Doc, what do you think it is?"

Share this post


Link to post
Share on other sites
The fix that I described is for pre-MS1 snapshots. If you are using MS2, I dont think this fix would work... BUT... It could work the other way...  

 

In PRODUCT_INFO.PHP, do you have code that references product_info_values? If so, try changing it to product_info and see if that helps.

 

For example...

 

<?php echo $product_info['products_price']; ?>

 

versus....

 

<?php echo $product_info_values['products_price']; ?>

 

Who knows, its worth a try. Do you have a link to see the error on one of your pages that I can see the error? I would be interested to see where the error is on the page. That will help to narrow down what piece of code is having the issue.

 

Let me know.

 

-R

 

It really has me baffled. I went into PHPMyAdmin and made sure that I had no NULL or Zero values. then I spent hours slecting each product in my store watching the error_log file in another window to see which one triggers it. could not find it. as I mentioned above, it is not displaying the warning on the screen, only writing the warning to error_log file.

 

I can't help but wonder if something else calls product_info.php that might be generating in the warning???

 

in any case, my store is here: http://www.lildevilmotorsports.com you will see that the contrib works fine and calculates the savings % accurately now even for products over $999.99 but generates 4-5 warnings a day.....

 

:?

Share this post


Link to post
Share on other sites

Carrerarod,

 

For the novice,

can you please publish the code that worked for you in resolving the price display of products above 999,99?

 

Thanks in advance,

 

Deltablue

Share this post


Link to post
Share on other sites
Carrerarod,

 

For the novice,

can you please publish the code that worked for you in resolving the price display of products above 999,99?

 

Thanks in advance,

 

Deltablue

 

Did the file I sent you work for you?

Share this post


Link to post
Share on other sites

Sorry to answer this late.

The file you sent did not work.

I am still having problems with the savings above $999.99.

Share this post


Link to post
Share on other sites
To the substr lines, e.g.
$no_savings = substr(($currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id']))), 1);

add a preg_replace to get rid of the commas before converting to floats, e.g.

$no_savings = preg_replace("/,/", "", substr(($currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id']))), 1));

No testing has been done on this. Use at your own risk.

 

It might make sense to do an sscanf instead of the preg_replace/substr pair, but I would want to try it before recommending any actual code. I also wonder if the currencies class might not have a numeric return that would work better than the string returned by display_price.

 

Good luck,

Matt

 

This worked for me, however, when I have a special price, I get 0.00s as the list price and our price.

 

e.g.

 

List Price: 0.00

Our Price: 0.00

You Save: 6%

 

Any suggestions would be appreciated. thanks.

Share this post


Link to post
Share on other sites
To the substr lines, e.g.
$no_savings = substr(($currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id']))), 1);

add a preg_replace to get rid of the commas before converting to floats, e.g.

$no_savings = preg_replace("/,/", "", substr(($currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id']))), 1));

No testing has been done on this. Use at your own risk.

 

It might make sense to do an sscanf instead of the preg_replace/substr pair, but I would want to try it before recommending any actual code. I also wonder if the currencies class might not have a numeric return that would work better than the string returned by display_price.

 

Good luck,

Matt

 

This worked for me, however, when I have a special price, I get 0.00s as the list price and our price.

 

e.g.

 

List Price: 0.00

Our Price: 0.00

You Save: 6%

 

Any suggestions would be appreciated. thanks.

<?php

}

if ($new_price = tep_get_products_special_price($product_info['products_id'])) { 

$list_price = '<s>' . $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) . '</s>'; 

$our_price = '<span class="productSpecialPrice">' . $currencies->display_price($new_price, tep_get_tax_rate($product_info['products_tax_class_id'])) . '</span>'; 

//get the list price and special price and then display the savings 

$no_savings = preg_replace("/,/", "", substr(($currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id']))), 1));

$now_savings = preg_replace("/,/", "", substr(($currencies->display_price($new_price, tep_get_tax_rate($product_info['products_tax_class_id']))), 1)); 

$now_savings = $now_savings + 0.0; 

$savings_b = (($now_savings / $no_savings) * 100); 

$savings = (100 - $savings_b);

$savings = round($savings);



} else { 

$list_price = preg_replace("/,/", "", substr(($currencies->display_price($product_info['products_retail_price'], tep_get_tax_rate($product_info['products_tax_class_id']))),1)); 

$list_price =$list_price + 0.0;

$our_price = preg_replace("/,/", "", substr(($currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id']))),1));

$our_price = $our_price + 0.0;

$savings_a = (($our_price / $list_price) * 100);

$savings = (100 - $savings_a);

$savings = round($savings); 

}?>

<p></p>

<center>List Price: <? echo "$"; echo number_format($list_price, 2); ?><br> 

<strong>Our Price: <? echo "$"; echo number_format($our_price, 2); ?></strong><br> 

<font color="#FF0000">You Save: <? echo $savings. "%"; ?></font>  

[/CODE][CODE]

Share this post


Link to post
Share on other sites

I have the EZ Fields Installed and it is a wonderful addition to my site.

 

I am wanting the amount saved to be listed as well (ie. $6.99, not just the %). Does anyone know how I can have my listing to look as follows?

 

List Price: $27.98

Our Price: $20.99

Savings: $6.99 (25%)

Share this post


Link to post
Share on other sites

Peter -

 

I have the savings amount, but not the percentage on my site. You should be able to combine the code below from product_info.php with the percentage code you have to get what you want.

 

Relevant code sections:

? ? if ($new_price = tep_get_products_special_price($product_info['products_id'])) {

? ? ? $products_price = '<s>' . $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) . '</s> <span class="productSpecialPrice">' . $currencies->display_price($new_price, tep_get_tax_rate($product_info['products_tax_class_id'])) . '</span>';

? ? ? $savings = $product_info['products_list_price'] - $new_price;? ?

? ? } else {

? ? ? $products_price = $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id']));

? ? ? $savings = $product_info['products_list_price'] - $product_info['products_price'];

? ? }

? ? ? ? ? ? <td class="pageHeading" align="right" valign="top">

? ? ? ? ? ? ? <table border="0" width="100%" cellspacing="0" cellpadding="0">

? ? ? ? ? ? ? ? <tr>

? ? ? ? ? ? ? ? ? <td class="pageHeading" align="right" valign="top">list price: <s><?php echo $currencies->display_price($product_info['products_list_price'], tep_get_tax_rate($product_info['products_tax_class_id'])); ?></s></td>

? ? ? ? ? ? ? ? </tr>

? ? ? ? ? ? ? ? <tr>

? ? ? ? ? ? ? ? ? <td class="pageHeadingPrice" align="right" valign="top">price: <?php echo $products_price; ?></td>

? ? ? ? ? ? ? ? </tr>

? ? ? ? ? ? ? ? <tr>

? ? ? ? ? ? ? ? ? <td class="pageHeadingSavings" align="right" valign="top">you save: <?php echo $currencies->display_price($savings, tep_get_tax_rate($product_info['products_tax_class_id'])); ?></td>

? ? ? ? ? ? ? ? </tr>

? ? ? ? ? ? ? </table>

? ? ? ? ? ? </td>

 

P.S. I named the new database field "products_list_price". The original contribution was "products_retail_price."

Edited by MattM

Share this post


Link to post
Share on other sites

I have installed this and after a couple of little problems I have it working fine with one exception. If I put an item on special it changes the the retail price to my normal selling price and gives me the savings from that. So a product would change

 

from

 

List Price: $ 47.45

 

Our Price: $28.95

 

You Save: 39%

 

to this

 

List Price: $ $28.95

 

Our Price: $$15.95

 

You Save: 45%

 

When it should really be this

 

List Price: $ 47.45

 

Our Price: $15.95

 

You Save: 59%

 

Well if anyone has any ideas that would be great.

 

Thanks

Richard


The Knowledge Base is a wonderful thing.

Do you have a problem? Have you checked out Common Problems?

There are many very useful osC Contributions

Are you having trouble with a installed contribution? Have you checked out the support thread found Here

BACKUP BACKUP BACKUP!!! You did backup, right??

Share this post


Link to post
Share on other sites

Thanks for the contribution, its really worth. I installed it and it is working great except for one thing. In the file advanced_search_result.php when one clicks the the link "Retail" (top 5th column) it gives an SQL syntax error.

1064 - You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'limit 0, 20' at line 1

select distinct m.manufacturers_name, p.products_image, m.manufacturers_id, p.products_id, pd.products_name, p.products_price, p.products_retail_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from products p left join manufacturers m using(manufacturers_id), products_description pd left join specials s on p.products_id = s.products_id, categories c, products_to_categories p2c where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '1' and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and (IF(s.status, s.specials_new_products_price, p.products_price) >= 4) and (IF(s.status, s.specials_new_products_price, p.products_price) <= 6) order by limit 0, 20

 

All the other links work fine the only link with error is the one which has sort value = 5a, so the link is like

http://www.somesite.com/advanced_search_result.php?inc_subcat=1&pfrom=0&pto=500&page=1&sort=5a

 

I tried to search for limit in the file advanced_search_result.php but there is no occurence of the word limit in that file als there are 2 occurences of "order by" in the file (I am not sure if somethings wrong with them).

 

I dunno if everybody faces this problem or is it just me?

 

I am not a PHP expert but I think that since we added more columns, we should have also edited this line

 

Line 304 (for me) in advanced_search_results.php

for ($i=0, $n=sizeof($column_list); $i<$n; $i++) {

 

to

for ($i=0, $n=sizeof($column_list); $i<=$n; $i++) {

Please note that = sign or may be change the variable "$column_list" Am not sure how it can be fixed.

 

Any kind of help will be appreciated.

 

Thanks

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×