How do I find the qty of products ordered for a specific attribute option in Ubercart?
I'm trying to make a cu开发者_如何学JAVAstom order summary module for Ubercart/Drupal that will display information something like this:
S M L Prod1 10 20 40 Prod2 0 15 0
where S
, M
, and L
are options for a custom attribute (size in this case), and the numbers are the quantities ordered of each product of each size.
I notice that the selected option is specified in the data
field for the product in the uc_order_products
table of the database. I can figure out all the arithmetic and everything if someone can tell me a good way of finding all the uc_order_products
rows which contain a specific option for a specific attribute. I'd even be happy with just a simple way to return the data
field as an object or associative array.
Alternate solutions involving Ubercart's API are also welcome, but from what I saw in the docs, there don't really appear to be functions for this kind of thing.
Thanks!
I found my answer in PHP's own unserialize()
. I'd never had any experience with serialization in PHP, so I didn't recognize the format when I saw it.
精彩评论