0

On a website I'm developing, there's a plan that users could buy some "online" products (or e-products) cheaply via PayPal, and than give these products to each other as a present.
For example, one user could buy a star (or more) for 1€, and send this star to another user he/she likes as a gift.
So nothing would be shipped, nothing would be downloaded.
I already have Ubercart set up with a PayPal Sandbox API key (there will be other products too), so I can see that online transactions seem to work successfully for products that can be shipped.

  1. How can I create products that can not be shipped, can not be downloaded, just simply purchased and registered, assigned to a given user (like an "online" product, which users can utilize on an online surface)?
    I could create a "star" product in my Ubercart webshop, let users buy it, and than check this type's stuffs in Ubercart tables.

  2. After a successful purchase, how could I check the order id (for the "star" product), and store the purchase process in my own tables to let users present these "online" products to each other (there would also be a field to whom it was sent) and register when this whole thing happened, and that one user already took this opportunity?
    (To let you understand why it's needed: there would also be a little icon on the site indicating that users already have e.g. 12 stars that could be virtually given to another user; besides, there would be another icon indicating the user got a star from another user [which user gave it, and when]. I would also like to generate an own unique code for these stars to utilize them later for example for a draw!)

Any good ideas are appreciated. Ask if anything isn't quite clear!
Thank you in advance!

1 Answer 1

1

OK, solved it with Conditional Actions!

  1. I created a new product class on /admin/store/products/classes site. Let's call it "My Stuff" (class id: my_stuff).
  2. The previous step created a new content type with the "My Stuff" name. So I went to "Create content > My Stuff" (/node/add/my-stuff).
  3. I left "Product and its derivatives are shippable." UNCHECKED (as I didn't to be shipped). Gave it an own SKU, sell price, description, uploaded an image, etc. as usual. OK, product created.
  4. Went to "Conditional actions" (/admin/store/ca ; don't forget to enable this module), "Add a predicate" (/admin/store/ca/add).
  5. Gave it a title, set "Customer completes checkout" trigger, gave a description, set my own class, set status to Enabled, pushed "Save predicate" button.
  6. Under "Conditions" tab, selected "Check an order's products", pushed "Add condition" button.
  7. Under "Product models:", I selected the SKU given in step 3.
  8. Clicked on "Actions" tab. Selected "Execute custom PHP code", pushed "Add action" button.
  9. Here I could "play" with the $order and $account variables in my custom code, and this was the key. This way I could loop through $order->products array (with for or foreach), reach the customer's user id via $order->uid (or $account->uid), read quantities (in the loop, with e.g. $order->products[$product_index]->qty, where $product_index is the actual index of the loop steps) and save them in my own database tables with db_query() function. Everything needed could now be saved in my own tables where they could be handled the appropriate way, so everything works fine now. I'm happy. cool

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.