Only 1 product at a time in osCommerce

Over at the official osCommerce forum, someone asked about the possibility of only allowing a buyer to select 1 of each product.  My answer was to amend the display of the shopping cart and the shopping cart class…

It’s fairly easy.  What I am going to show you is amending the display using HTML and CSS, then a bit of PHP code to only add 1 of a product in the class file.

Step 1:  Make the quantity box readonly and look nicer.

As someone who has done a lot of HTML over the years I know that the attribute called “readonly” makes an input “read only”!  So I add this to the shopping cart page.  Open up shopping_cart.php and find

[php]’text’ => tep_draw_input_field(‘cart_quantity[]’, $products[$i][‘quantity’], ‘size=”4″‘) . tep_draw_hidden_field(‘products_id[]’, $products[$i][‘id’]));[/php]

Change it to:

[php]’text’ => tep_draw_input_field(‘cart_quantity[]’, $products[$i][‘quantity’], ‘size=”4″ id=”clubosc” readonly=”readonly”‘) . tep_draw_hidden_field(‘products_id[]’, $products[$i][‘id’]));[/php]

You can see that I have added the readonly attribute and given it a css ID called “clubosc”.

Step 2:  Amend the look of the box using .css

Open up stylesheet.css and add this code;

[php]#clubosc {
border: none;
text-align: center;
background: transparent;
}[/php]

Add something to the cart and your quantity box now looks like this:

Whereas the usual look is like this:

Now, because we have made the contents of the quantity field readonly, we have to ensure that not more than 1 product can be added. At the moment a buyer could return to the product page, and click “buy” again, ending up with 2 of the same item in his cart.

Step 3: Making only 1 buyable…

Open up /includes/classes/shopping_cart.php and find this line of code:

[php]$this->update_quantity($products_id_string, $qty, $attributes);
} else {
$this->contents[$products_id_string] = array(‘qty’ => (int)$qty);[/php]

Simply change both $qty to (int)1. So you end up with;

[php]$this->update_quantity($products_id_string, (int)1, $attributes);
} else {
$this->contents[$products_id_string] = array(‘qty’ => (int)1);[/php]

And that is it. 3 easy steps to allow customers to only buy a maximum of 1 of each product.

Sage Pay in RC3 osCommerce

Looks like Sage Pay is finally been added to the core code of osCommerce for RC3.  Sage Pay was formerly known as Protx, and it is (and has been) the best 3rd party providers of Card services for the small merchant.

You can read more about Sage Pay at their page on the osCommerce website;
http://addons.oscommerce.com/service/sage_pay

Probably the most popular is the “form” version, but if you are looking at going with Sage Pay, I highly recommend using Server or Direct. Both these are more professional, but only you can know what is right for your shop (and your pocket!).

Anywy, it’s good to see these added to RC3.

Action Recorder in RC3 osCommerce

Just looking at what is 99% of RC3 osCommerce, and found an interesting new feature called “Action Recorder”. What this does is record the actions of people using your store.

For starters, the “Tell A Friend” and “Contact Us” forms are integrated…

This shows the admin area for setting the number of minutes by which the form can be used. In the example, it can be used just once in 15 minutes.

If a user sends an email via Contact Us, then tries to send again within 15 minutes, they get this message;

And in the Admin section, this is recorded along with IP address etc;

Sweet little function that should help to deter spammers and the like. I’m wondering what else can be plugged into the Action Recorder – there’s lots of possibilities for this.

More osCommerce Breadcrumb funkiness

I really wanted to try out a menu system that I found online, in osCommerce. The menu system is the one at Izzy Menu…and integrating it into osCommerce was fairly simple.

The code from the Izzy site is quite straightforward, so I simply used it on the breadcrumb osCommerce function. You can see the results in this video;

It looks pretty good and (as far as I recall) only needed changes in one osCommerce file and the stylesheet,as well as moving the breadcrumb to the top of the header.php file. I’ve tested it in Firefox and IE8 and it seems OK.

Really interesting osCommerce project

I just completed a really interesting osCommerce project. I gave a shop a makeover based on the clients PSD file – easy enough. Then I had to change the way that the products display.

1. remove the product_info.php page entirely
2. create a new products module to display product_info in the index page or the category page.

That probably sounds a bit weird, but if I show you a couple of images, it might be more clear. This is the standard index page, the “new products” module is located on the right. The module on the left is a recoded “new products for month” module.

So, the “new products” module changes when the shopper clicks on an item in the “new products for month” module. As so;

In other words, the “month” module does not now click through to the product_info page at all. Similarly, inside a category is the exact same layout;

I also needed to have the “buy” button and a “wishlist” button on the new module. It’s osCommerce, but it is nothing like osCommerce – which is always a good thing in my opinion.

View All link on advanced_search_result.php in osCommerce

Someone wanted the ability to add in a “view all” link to the results page of the advanced search in osCommerce. As I’, one for doing things in the simplest way possible, my idea was to simply add a new link saying “view all”, which when clicked will reload the page without the listing_split.

Easy as 123. Here’s the results in action:

osCommerce View All Link

Please note that for this example I changed the max listing of search results to just 2 – to more easily show the paging and view all effect. Yours is probably set at 20.

Coupons with Category Exclusions

I had a client who really needed the possibility of excluding some products from the coupon discount system. After some thinking we came up with a way to exclude whole categories from being discounted. I’ll illustrate with a simple example;

Category Coffee is excluded from discounts.
Category Tea is NOT excluded.

We are using a 50% coupon, and the buyers buys;

Coffee Beans @ $50 per pack and Tea Bags @ $50 per pack

So, the shopping cart looks like this (exactly as normal):

I then insert the 50% coupon code, and the view changes to this:

As you can see the coupon has deducted 50% of the allowed item, and nothing from the disallowed item! In addition, you can see that the shopping cart infobox also shows the correct deduction!

Carry on through the checkout:

You can see that the order_totals are correct; $100 (subtotal) LESS $25 (50% of the allowed product) PLUS $5 (shipping) == $80 to pay

And if we now look at the Admin area for the order:

We can see the correct order_totals here too.

This is an extensive overhaul of the coupons system and is in Beta Testing right now.

Text Product Attribute in osCommerce

I wanted to make a little experiment to show the possibility of using a small piece of javascript to show the textual input in an osCommerce product_info.php page. Anyone using osCommerce will know that text inputs is not possible in standard osC 2.2 releases, though it will be a standard feature of v3.

As I’m running 2.2 for this project, I had to install “option types v2”, which did not take very long at all.

I then set up a “slogan” text input attribute and applied it to a product. All easy.

My idea was to somehow have the text appear as the person typed in the slogan – I thought it would be a fun project to code and be useful to future clients.

Here’s the video of it in action… http://vimeo.com/8619844

The letters that appear are actually images, and the whole thing is controlled by a few lines of jquery javascript. I think it looks pretty nice. One possibility for this is for Tshirt sellers to enable buyers to write slogans. Instead of having the letters below (like I have in the video) it would be just as simple to overlay them onto an image of a tshirt.

Another possibility is for engraving of trophies or medals. I suppose really anywhere where a name is required to make the product!

Voucher Module for Burts Coupon System

Well, I have had more than a handful of requests for this, so it’s time to think about getting it coded. It was always my intention to do this, but other work of course gets in the way.

In order to raise the necessary funds for coding to be started, I’m going to raise the price of the coupons system to $99. The price includes installation and support, and ongoing free updates.

However, for the next 20 coupon system buyers the price will remain at $50, then the next 10 will pay $75. After this $99 will be charged.

I have no release date set for the vouchers module of the coupons system, but everyone who has already purchased my coupons system will get the update free of charge, just as soon as it is coded and beta tested.

So…if you were umming and ahhing about my coupon system, either because of price or because it doesn’t have vouchers, now is the time for you to stop prevaricating and get an install done.

As another client has it installed, I will update this thread with the number of spots remaining at the lower prices.

To go forward with an instal discussion, please email me on oscshops@gmail.com

Yes, things are delayed – official from osQuantum

Well, it had to happen. After all the debate and hysteria over the past 12 months from Rhea Anthony et al, over at oscanswers, oscommerce project, osquantum and their supporters and detractors, the official word is that the release of the much vaunted osQuantum is to be “delayed”.

That’s a pity as I was looking forward to seeing the new cart and comparing it in use against osCommerce. You can read the exact words from Rhea Anthony at http://forums.osquantum.org/index.php?s=&showtopic=1449&view=findpost&p=11936 where the main gist of the post places the blame for delay on Kohana. A pity 🙁

If any good came out of the last year of public mud throwing, it’s the fact that osCommerce now has two great developers on board, with more to follow – which will speed up development nicely. osCommerce will shortly be releasing 2.2 rc3 which willl mark the end of the v2 cycle – after which full development will continue on v3.

It is a disappointment to me that osQuantum will not be releasing the cart on schedule, and is now not willing to even give a release date at all. However it does stop them from their main attack against osCommerce, which was the inability to give release dates and slow development. C’est la vie!