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

CommentFileSizeAuthor
#3 export-1446.txt39.88 KBdpico

Comments

dpico’s picture

I forgot to say that I'm using Commerce Kickstart.

jantoine’s picture

Hey 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.

dpico’s picture

StatusFileSize
new39.88 KB

Hi 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?

jantoine’s picture

Component: Code » Documentation
Category: Bug report » Support request
Status: Active » Fixed

Hey 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.

dpico’s picture

Thanks! 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?

jantoine’s picture

The 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.

dpico’s picture

Thanks 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.

jantoine’s picture

Are 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.

dpico’s picture

Thanks 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:

foreach ($line_items as $line_item) {
    if(isset($line_item->commerce_product)) {
      $values = array();
      $values[] = $line_item->quantity->value();
... etc.

The export seems to work for all cases with this change.

jantoine’s picture

Hey 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.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.