Storing monetary amounts in db? Use decimals, not floats!

Lot’s of people will be surprised (or shocked, when it happens in production) when they see that mysql can work like this:


SELECT transaction_id, amount FROM transactions WHERE amount>20.5




SELECT transaction_id, amount FROM transactions WHERE amount=20.5


No rows

So, 20.5 is really greater than 20.5 in sql database. Sometimes. Read more »

Using Ubercart to sell files: ui improvements and creating file feature programmatically

uc_file module that allows selling files in Ubercart is definitely not perfect in terms of API, but it is a nice piece of functionality.
We’ve just finished creating one e-book store which has product-import feature.
Each product has multiple formats (pdf, epub, rtf) - some products can have pdf+epub, some can have just pdf, others have all three formats attached.

On product page, we wanted to show nice block like this:

Ubercart file downloads

where pdf and doc are just text for regular users, and download links for users that already bought this book.

All the code was created for Drupal 7 + Ubercart 7.x-3.x Read more »

Commerce Product Constructor

Today I’ve made another decision to postpone using Commerce in our project where customer needed simple e-shop. I’ve actually made such decisions several times already, and that makes me feel unhappy.
I would like to say that I really enjoy Commerce presentations, (like everyone of you, huh?), and test installations are working great!
The idea of Drupal-way, and Rules, and Views-everywhere rocks.

But… Commerce is being developed for a long time already, and you still can’t show it to your customers if they need to log in to admin section of their website!


That’s node display + product entity problem.

In Commerce, product entity is a primary thing, and this is an item that holds product-specific data like SKU and price. Read more »

Additional CCK powered price for product in Ubercart

I was not updating my blog for a while - it’s summer here :)
I’ve just returned back from my business trip to US, Alaska, where I helped guys from shipito.com killer to automate their warehouse and create good user control panel in their website (everything is Drupal-powered here!). I’ve also spent several days surfing in San Diego. It’s so exciting to realize that Drupal knowledge can give you an opportunity to visit such amazing places and meet interesting and smart people all over the world!

Today I will tell you about small, but cool feature which makes Ubercart website pricing even more flexible.
The code was designed to work in Drupal 6.x + Ubercart 2.4.

There is a lot of Ubercart modules that provide separate prices for some specific conditions. Read more »

EMS shipping module for Ubercart

I’ve just created EMS Russian Post shipping module. It will be useful for store owners in Russia.

The module supports delivery price calculation outside Russia (and in Russia, obviously).
Caching was implemented to minimize requests to EMS Russian Post website.

Module screenshots:
EMS Russian Post

No connection to EMS website” use case demonstration:
EMS no connection

Settings page: Read more »

Sending emails with attachments in Ubercart

Ubercart has its own CA (Conditional Actions) module which purpose is to execute some actions when certain events happen — you can find CA configuration screen on admin/store/ca/overview. The most typical CA use case is sending emails to customers when order is placed. But, I couldn’t find any answers on how files can be attached to these emails. Sending attachment can be an essential feature of your Ubercart store - potentially, you can send your software product attached to email to customer when order was approved, or you can send .pdf with invoice for printing, and lots of other use cases. Here is the related thread on ubercart.org with no answers: http://www.ubercart.org/forum/support/10634/sending_file_attachment_orde… Read more »

Adding "Price" field to Ubercart cart page

On the /cart page of Ubercart store, you can usually see such fields:

That’s total price per row, and amount of products per row.

For a customer project, I wanted to add single item price to this page, to make it look like this:

Read more »

Drupal association member