Welcome Guest, Not a member yet? Register   Sign In
Cart Class does not return the item when price is zero
#1

[eluser]chikoi[/eluser]
Hi. I'm using the Cart Class to handle my items (some of there are priced as 0), however, the cart does not return the item being priced as zero. Is there any simple and quick workaround for this?


Thanks.
#2

[eluser]chikoi[/eluser]
NVM, i figured this out!


You have to comment out or apply some changes on line 197 of system/libraries/Cart.php

Code:
//$items['price'] = trim(preg_replace('/(^[0]+)/i', '', $items['price']));

Hope this helps someone having the same issue. =)
#3

[eluser]nomikos3[/eluser]
Hi, thanks for guide me to that file.

Code:
// Prep the price.  Remove anything that isn't a number or decimal point.
$items['price'] = trim(preg_replace('/([^0-9\.])/i', '', $items['price']));
// Trim any leading zeros
$items['price'] = trim(preg_replace('/(^[0]+)/i', '', $items['price'])); // <-- clears our single zero

So to avoid hack the core it's preferable use 0.00 instead 0 (zero).
#4

[eluser]InsiteFX[/eluser]
You should extend a Core Class not modify it!

InsiteFX
#5

[eluser]chikoi[/eluser]
Hi NomikOS3 and InsiteFX,

Thanks for the heads up. I'll go ahead and extend the class instead of modifying it.




Theme © iAndrew 2016 - Forum software by © MyBB