inkredible Posted September 5, 2017 Share Posted September 5, 2017 I would like to extend the "purchase notifications" in the commerce application so that it will send the product's custom field which I have setup in that email as well. In my oppinion it should be a native feature but I need that feature as soon as possible. Can you point me in the right direction what to do therefore? Link to comment Share on other sites More sharing options...
bfarber Posted September 5, 2017 Share Posted September 5, 2017 You will want to modify the email template (Customization tab in AdminCP) to loop over the fields and include them. Link to comment Share on other sites More sharing options...
inkredible Posted September 5, 2017 Author Share Posted September 5, 2017 9 hours ago, bfarber said: You will want to modify the email template (Customization tab in AdminCP) to loop over the fields and include them. Ok that sounds amazing, unfortunately I don't see a custom field tag offered for the "purchase notifications" email template. Can you help me out there, how can I use the referenced custom fields for this product? Link to comment Share on other sites More sharing options...
newbie LAC Posted September 6, 2017 Share Posted September 6, 2017 12 hours ago, inkredible said: Can you help me out there, how can I use the referenced custom fields for this product? $purchase->custom_fields return an array like array('fid' => 'value', 'fid' => 'value', 'fid' => 'value') Link to comment Share on other sites More sharing options...
inkredible Posted September 6, 2017 Author Share Posted September 6, 2017 34 minutes ago, newbie LAC said: $purchase->custom_fields return an array like array('fid' => 'value', 'fid' => 'value', 'fid' => 'value') I looked into the nexus/sources class and I thought I could use the public methods there. Unfortunately it didn't work, maybe you can explain why. I tried: {$purchase->get_member()->get_name} and {$purchase->get_custom_fields()} Both returned null / or an empty string. Edit: Your approach didn't work either. Is it because I create the invoice from the backend? I do provide values there for my custom fields though and the member name should still work then right? Link to comment Share on other sites More sharing options...
bfarber Posted September 6, 2017 Share Posted September 6, 2017 If a method is prefixed with get_ then it is a getter and you typically exclude that. $purchase->member()->name Yes, this data should be available regardless of where the purchase was created. Link to comment Share on other sites More sharing options...
newbie LAC Posted September 6, 2017 Share Posted September 6, 2017 1 hour ago, inkredible said: and {$purchase->get_custom_fields()} You should work with variable as with an array {{foreach $purchase->custom_fields as $k => $v}} Some code here {{endforeach}} 1 hour ago, inkredible said: Is it because I create the invoice from the backend? Maybe yes or maybe it's a bug. 45 minutes ago, bfarber said: If a method is prefixed with get_ then it is a getter and you typically exclude that. You should exclude () also $purchase->member->name Link to comment Share on other sites More sharing options...
inkredible Posted September 6, 2017 Author Share Posted September 6, 2017 5 minutes ago, newbie LAC said: You should work with variable as with an array {{foreach $purchase->custom_fields as $k => $v}} Some code here {{endforeach}} Maybe yes or maybe it's a bug. You should exclude () also $purchase->member->name Thanks for the hint, I noticed that there is an example for the customer's display name on the top of that email template. Unfortunately I still wasn't able to figure out the custom_fields issue. I tried your foreach approach as well, but it appears the array is empty as it doesn't print anything. This is what I've added: {{foreach $purchase->custom_fields as $k => $v}} <tr> <td dir='{dir}' width='200' style="font-family: 'Helvetica Neue', helvetica, sans-serif; font-size: 14px; color: #333333; line-height: 21px" align='right'> <strong>{$k}</strong> </td> <td dir='{dir}' style="font-family: 'Helvetica Neue', helvetica, sans-serif; font-size: 14px; color: #333333; line-height: 21px" align="left"> {$v} </td> </tr> {{endforeach}} Thanks for all the help so far! I hope I get it working in the end Link to comment Share on other sites More sharing options...
newbie LAC Posted September 6, 2017 Share Posted September 6, 2017 1 minute ago, inkredible said: I tried your foreach approach as well, but it appears the array is empty as it doesn't print anything Run SELECT ps_custom_fields FROM nexus_purchases WHERE ps_id=X; Change X on purchase ID Link to comment Share on other sites More sharing options...
inkredible Posted September 6, 2017 Author Share Posted September 6, 2017 1 hour ago, newbie LAC said: Run SELECT ps_custom_fields FROM nexus_purchases WHERE ps_id=X; Change X on purchase ID All of these are empty arrays, so apparently it's a bug @bfarber? Creating an invoice manually (for example to correct a missing order due to the PayPal problems) won't submit the custom fields, even though I can provide them when creating the invoice. Edit: It's NOT exclusive to the admin panel. I changed the price to 0€ and purchased it as normal member, the ps_custom_fields array is still null in nexus_purchases. Is there a place in the admin panel where I would see the provided custom fields which are related to an order? Link to comment Share on other sites More sharing options...
bfarber Posted September 7, 2017 Share Posted September 7, 2017 I would recommend submitting a ticket at this point so we can take a look. Indeed if you have custom fields set up and you are filling those values in, but the values aren't being stored, we need to investigate why. Customizing the email template afterwards should be as easy as has been shown here. Link to comment Share on other sites More sharing options...
inkredible Posted September 7, 2017 Author Share Posted September 7, 2017 42 minutes ago, bfarber said: I would recommend submitting a ticket at this point so we can take a look. Indeed if you have custom fields set up and you are filling those values in, but the values aren't being stored, we need to investigate why. Customizing the email template afterwards should be as easy as has been shown here. I've already filed a ticket 24h ago :-). #989225 if you want to take a look at it yourself, it's still in the T1 support level I think Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.