Hi
Jon Antoine, thanks for this useful module! This can be really useful for connecting Drupal Commerce sites with other systems, together with Rules FTP. Thanks so much.
I'm encountering a problem, though. When I activate the module and the rule "Export an order and email on checkout completion", my site produces the following error after reviewing the cart order and clicking next to proceed:
Fatal error: Call to undefined method EntityValueWrapper::get() in /home/......./profiles/commerce_kickstart/modules/contrib/entity/entity_token.tokens.inc on line 241
Could you help me solve this? I don't have a clue.
Regards,
David
Comments
Comment #1
dpico commentedI forgot to say that I'm using Commerce Kickstart.
Comment #2
jantoine commentedHey dpico,
Did you apply the required patch mentioned on the project page? Also, if you've already applied that patch, ensure you are using v1.5 of the Entity API module. Please report back here if either of these resolved your issue.
Comment #3
dpico commentedHi jantoine,
Thanks for you help! I had applied it and I'm using v.15 of Entity API, but I guess I had done something wrong because I've done it again and now it works. The resulting file, though, keeps all tokens unparsed (see attached file). I mean, the real data from the order are not populated into the txt file that is generated. Is this due to any other missing configuration?
Comment #4
jantoine commentedHey dpico,
Yes, the default template file just dumps the entire order object. Look at some of the other templates like the CSV template for examples.
Comment #5
dpico commentedThanks! Just one more question, please. How can I use the CSV template in templates/commerce-export-orders--csv.tpl.php ? I've tried many values for the "Dynamic template name. The dynamic portion of the template name to be used." in the "Export commerce orders" action, with no luck. I've used "commerce-export-orders--csv.tpl.php", "commerce-export-orders--csv" and "csv" but none of them seem to work. Am I in the good direction?
Comment #6
jantoine commentedThe dynamic portion should be the text after 'commerce-export-orders--' and '.tpl.php'. In the provided example rules, it is 'csv'. You may need to copy both template files into your theme folder.
Comment #7
dpico commentedThanks again jantoine! That did the trick. I copied both template files into my theme folder, I used 'csv' as the dynamic portion and now it works.
However, it only works when it's the admin user who generates the order. For plain users I get some warnings ("Unable to get a data value. Error: Unknown data property commerce_product." followed by "Unable to evaluate action commerce_export.") and an error ("Unable to get variable export_file, it is not defined."). The rule is aborted and the export file is not generated. Is it necessary to set permissions in any particular way so the order is also exported for plain users? Sorry if this has an obvious answer that I should know. I'm quite a newbie with Rules.
Comment #8
jantoine commentedAre you using the same theme between the admin user and other users? Also, this could possibly be a Drupal permission issue. I would test by creating a user with a role that has all commerce related permissions. If that doesn't work, start with a role that has all permissions. If that still doesn't work, I'm not sure what could be going on. If it does work, begin taking away obvious permissions that could possibly break the process until you find the one that breaks it.
Comment #9
dpico commentedThanks again, jantoine. The problem doesn't seem to be related to permissions but to payment methods. If there is no payment, then the order is exported correctly. If the user activates some payment method (I've tested Commerce Cheque and Commerce Bank Transfer), then the variable $line_items in the example template commerce-export-orders--csv.tpl.php gets an extra element that doesn't contain any product line, therefore making references to $line_item->commerce_product fail.
I've added the condition if(isset($line_item->commerce_product)) to the loop:
The export seems to work for all cases with this change.
Comment #10
jantoine commentedHey dpico,
Now that you mention it, I had to make a similar change in a template file copied to a custom theme for the same reason. I'll look at updating the examples to account for that.