help writing a rule to add a purchased file to customer account after payment received - drupal 7 and ubercart

Events happening in the community are now at Drupal community events on www.drupal.org.
tgldesign's picture

I have found a problem after an upgrade from d6 to d7. When a user buys a file download, the files are not ascociated with their account even after payment is received, and I can't figure out how to write a rule for this to happen. I thought something was wrong with the download email not going out at first but this is the thing that's missing for me.

using ubercart / drupal 7

Comments

You might want to try this at

DanZ's picture

You might want to try this at http://www.ubercart.org/forum/support.

I don't know the full answer, but I can tell you this. Ubercart 2 uses Conditional Actions, where Ubercart 3 uses Rules, and they are not translated in the D6 -> D7 upgrade. You might want to make a fresh test install of D7 / U3 and turn on file download purchasing, and see how the Rules are set up there.

Just some random thoughts: Do you have the Ubercart File Downloads module enabled? Also, the trigger action that the Rule (if this is how it should be done) should work with is "Customer completes purchase".

thanks for helping. there

tgldesign's picture

thanks for helping. there seems like a missing trigger somewhere for adding the files to the order.

ive got the module checked. i tried a fresh install but the rules appear to be the same. the only difference is that 'Notify customer when a file is granted' is last in the list on the fresh install, but 4/7 in the list on the upgraded one.

is the 'Renew purchased files' rule the one that adds the purchased files to the order? this rule seems set up ok, but it isn't adding them.

the files do appear when i

tgldesign's picture

the files do appear when i look at the 'order' but when you go to the user's 'files' page (user/*/purchased-files) it says 'No downloads found'. there is an option to manually add the files. when I use this to manually add the files the website throws up this error:

Error
The website encountered an unexpected error. Please try again later.

The website encountered an

DanZ's picture

The website encountered an unexpected error. Please try again later.

Ah, now you're getting somewhere. That shows up when you have a bug, a database problem, or a system misconfiguration.

Enable all error messages and see if you can get something more informative.

Also, I can't guarantee that Ubercart uses Rules to do the job (I'm just not familiar with that part of the cart).

I can tell you that the documentation for what you want to do is at http://www.ubercart.org/docs/user/30476/selling_digital_goods_mp3s_photo.... If you haven't already, read that. Maybe it will help.

error code

tgldesign's picture

ok i went through the same process to get the "Error" as before but now it's showing the full error message now I enabled all the error messages. Can you see anything in there that can help me (I can't understand what I need to do with this info)?

PDOException: SQLSTATE[22003]: Numeric value out of range: 1264 Out of range value for column 'expiration' at row 1: INSERT INTO {uc_file_users} (fid, uid, pfid, file_key, granted, expiration, accessed, addresses, download_limit, address_limit) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9); Array ( [:db_insert_placeholder_0] => 144 [:db_insert_placeholder_1] => 644 [:db_insert_placeholder_2] => [:db_insert_placeholder_3] => dPrqZzEB5XwhGOhReVL0zvY6X0Mdwk65o9C1q8Qp1AU [:db_insert_placeholder_4] => 1365500694 [:db_insert_placeholder_5] => 2943341094 [:db_insert_placeholder_6] => 0 [:db_insert_placeholder_7] => a:0:{} [:db_insert_placeholder_8] => 10 [:db_insert_placeholder_9] => 0 ) in drupal_write_record() (line 7106 of /home/sites/*.com/public_html/includes/common.inc).

The main other error I see is

tgldesign's picture

The main other error I see is this one, but it's probably unrelated:

there is a list of 10+ of the same thing...

Notice: Undefined index: module in FieldInfo->prepareInstanceDisplay() (line 610 of /home/sites/*.com/public_html/modules/field/field.info.class.inc).

sorry if all this isn't a rules problem by the way - its starting to look like database problems.

Yes, your database is messed

DanZ's picture

Yes, your database is messed up.

Did you run update.php? (Sorry, have to ask.)

Look at your database table {users} and make sure you have a user #0.

Good luck. Corrupted databases are hard to clean up. It may end up being easier to re-build your site and re-import your data.

For the main other error, you need a backtrace to find out what data it's erroring on. Install the Devel module. Enable Krumo error messages with a backtrace.

You can generally ignore PHP

krlucas's picture

You can generally ignore PHP "Notice" messages if you're not a developer. In fact, I disable them on production.

The PDO Exception above is telling you that you are trying to set the expiration date of the file to "2943341094" (or Mon, 09 Apr 2063 10:44:54 GMT) but that value is too big for the column. The expiration column is probably a signed integer which means its max value in MySQL is 2147483647 (which as a timestamp stands for Tue, 19 Jan 2038 03:14:07 GMT).

oh wow thanks krlucas. the

tgldesign's picture

oh wow thanks krlucas. the default setting for the file downloads was 50 years, so I changed it to 1 year, and the download limit from 10 to 5 to be on the safe side and it worked! now all I need to do is get the file download email link to be a one time only link - but i'll post about that in the ubercart project issues. Thanks for your help.

Cool. Glad it worked out.

krlucas's picture

Cool. Glad it worked out. If 50 years is an Ubercart default then that's a bug that should probably reported.

Rules

Group organizers

Group categories

Categories

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

Hot content this week