Post by MadScientist » Fri Jun 05, 2009 11:54 pm

Hello Everyone,

I'm new here and just wanted to say how much I like the OpenCart Platform. Well done to all involved.

I'm very new to PHP but have a little coding experience and would appreciate any guidance on the following.

Im trying to mod the cart so that Free products can be sold (aka given away). However not all products are free so some products will be sellable via the normal procedures. If I set the price of a product to zero thats fine but it still goes through the checkout trying to bill for zero! So I am hoping to do the following:
  • In the relevant catalog->view scripts, amend so if price is zero display "[Free]" instead of the actual price
  • On checkout (I havn't determined where this might happen) - if order total is zero then skip payment and go straight to order complete.
I have started the first part in catalog->view->...common->home and changed

Code: Select all

<span style="color: #900; font-weight: bold;"><?php echo $products[$j]['price']; ?></span><br />
to

Code: Select all

<span style="color: #900; font-weight: bold;"><?php if ($products[$j]['price']==0) echo "[Free]"; else echo $products[$j]['price']; ?></span><br />
but this changes all prices to [Free] (before and after screenshots attached)- Is there something wrong with the conditional check Or am I approaching this incorrectly. Any advice would be appreciated.... Thanks
before.gif

before.gif (64 KiB) Viewed 2793 times

after.gif

after.gif (64.54 KiB) Viewed 2793 times


Newbie

Posts

Joined
Fri Jun 05, 2009 8:35 pm

Post by Qphoria » Sat Jun 06, 2009 2:07 am

MadScientist wrote:

Code: Select all

<span style="color: #900; font-weight: bold;"><?php if ($products[$j]['price']==0) echo "[Free]"; else echo $products[$j]['price']; ?></span><br />
Price on the front end is a string because it includes the symbol. You are checking against an integer

You need to try if ($products[$j]['price']=='$0.00') with whatever symbol you want to use

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by MadScientist » Sat Jun 06, 2009 6:56 pm

Qphoria, many thanks for your assistance. I knew it was something silly. So I have updated all the relevant frontend pages. I had a little problem when trying to match the strings with the '£' sign so ended up taking the hex value of the zero string and using a switch statement to cover all the currencies (only with currency symbols in their normal positions). I considered using the ereg function and combining a check with strlen however the currency signs have different lengths for a zero value (*0.00) (US=5, EU=6, GB=7) so could mistakingly take $10.00 as a free item!

Code: Select all

<span style="color: #900; font-weight: bold;"><?php switch( bin2hex($products[$j]['price']) ){case "24302e3030": case "c2a3302e3030": case "302e3030e282ac": echo "[Free]"; break; default: echo $products[$j]['price']; break; } ?> </span><br />
However I need your advice again pls, The checkout procedure takes the customer through the payments processing procedure EVEN if the total order is *0.00 and Paypal does not accept 'free' orders. So what I'd like to do is on checkout verify if total = *0.00 and if thats the case then bypass payment (as this is not needed), log the order and pass the customer to 'checkout/success'.

Could anyone give me any hints on where I might need to address this and give me a starting point? Can this rule be set for OpenCart as a whole or do I need to modify individual payment modules?

Many Thanks,

Newbie

Posts

Joined
Fri Jun 05, 2009 8:35 pm

Post by GoGo OpenCart » Thu Nov 24, 2011 7:14 am

I just released an extension for doing that. This extension will display "Call for Price" or any other text that you like, for products that have 0 (zero) price. It works independent from different currencies, multiple currencies, left or right currencies, etc. With other words, all you need to do, is to install the extension, and put 0 price for the products you don't want to have prices.

It will also disable the "Add to Cart" button for 0 priced products, making it gray, so costumers can't add that product into the cart.

Look at the pictures to see how it looks like.

Extension's page: http://www.opencart.com/index.php?route ... on_id=4067

See all my extensions: https://www.opencart.com/index.php?rout ... 20OpenCart


User avatar
Active Member

Posts

Joined
Mon Nov 14, 2011 11:30 pm

Post by adida » Mon Jul 23, 2012 1:45 pm

Hello to OC users,

Is it possible to build up price from zero by adding options so that customers could put a system together - THEN request a price. Something like this http://store.apple.com/us/configure/MD771LL/A

Is the Call for Price module can help solving the issue?

Thanks.

Newbie

Posts

Joined
Mon Jul 23, 2012 1:22 pm
Who is online

Users browsing this forum: No registered users and 5 guests