Closed (outdated)
Project:
Commerce Email
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
13 Apr 2012 at 22:00 UTC
Updated:
2 Jun 2020 at 18:17 UTC
Jump to comment: Most recent
Comments
Comment #1
rtdean93 commentedThanks for this module... exactly what I needed.
One more question... I have a field that I have added to each product (field_product_category).
// Special treatment for a product, since we want to get the title from
// from the product entity instead of the line item.
How do I pull in a product field value for each ilne item?
Comment #2
andyg5000Hey rtdean,
If you look at the commerce_email_extras.module file line 18-22, these are the table headers. Lines 37-41 are the row fields that create the line items table. You can edit those to include your extra category header and fields. You'll have to dissect the wrapper object to pull out the category value. I'd recommend creating your own module from the sandbox one that I have created because I have no plans of making this any more than a sandbox module for proof of concept. Let me know if you need any help.
Thanks,
Andy
Comment #3
kevster commentedMany thanks - just what I needed - appreciated!
Comment #4
rtdean93 commentedAndy - I could use some direction.. Not sure how to dissect the wrapper object. Does the wrapper object include the product entity? The field I need is called 'field_main_title' which is an extra field for the product in addition to the regular title.
Comment #5
andyg5000Hey rtdean93,
The $line_item_wrapper does include the product entity in $line_item_wrapper->commerce_product. You'll need to reference that specific field in the wrapper. For example, the following gets the product title:
$line_item_wrapper->commerce_product->title->value()I imagine you can get your value by declaring the following:
$line_item_wrapper->commerce_product->field_main_title->value()You can also use the get PropertyInfo() method and use print_r or dpm (with Devel module) to browse the wrappers elements. For example:
print_r($line_item_wrapper->commerce_product->getPropertyInfo());Hopefully this helps!
Comment #6
andyg5000I have updated the sandbox module to include all product types and not just the standard 'product' bundle.
Comment #7
RMani commentedI downloaded the sandbox version , having difficulties in enabling this module could you please help
regards,
Rekha
Comment #8
minneapolisdan commentedThis looks promising, but has the sandbox disappeared? I couldn't access it.Never mind, I got it, thanks.Comment #9
brephraim commentedThis is nice, but unfortunately as written it doesn't support custom line item types.
Comment #10
jbekker commentedMmh, for some reason I get the SKU on the product TD and the product title is gone. I checked your code but I can't figure it out.
Comment #11
brephraim commentedIf a line item isn't of the "product" type, this is what happens, as a result of the "default" code.
Comment #12
andyg5000Hey All,
I haven't looked at this module/post since June. I'll try to take a look at the issues this week and follow up. I originally posted this issue and sandbox as a concept of how you could achieve a more detailed line items table. It's probably best to get with the maintainers of this module and come up with a solution that can be committed to it instead of trying to create a new add on module.
-A
Comment #13
brephraim commentedWell, I really appreciate this code, I was able to modify it to work for the custom line item types on my site, but unfortunately I'm not code savvy enough to be able to come up with a generic patch.
Comment #14
mrpeanut commentedWould love to see the sandbox module committed. It works great!
Comment #15
mrpeanut commented@andyg5000 — I realize this wasn't ever meant as a module or something that you are making customizations for, but is it possible to move the shipping line item under Subtotal? So, for example...
Line Items
Subtotal
Shipping Service
Total
Balance
Comment #16
mrpeanut commented@brephraim — Could you share how you modified the module to work with custom line items? I have a custom line item sampler and am having the same issue you were.
Comment #17
brephraim commentedFind the lines
And then insert this underneath:
Actually, now that I think of it, I'm pretty sure I altered the $rows array. The above code gives you the basic idea though, what you may be able to do to get it to work with the default config is to just delete the $rows declaration from the above code, and instead copy in the corresponding declaration from the
case (in_array($line_item_wrapper->type->value(), $product_types)):code block in the original module.Let me know if I can help in any other way.
Comment #18
mrpeanut commentedI wasn't able to get the custom line item to show up. Here's exactly what I entered underneath
switch ($line_item_wrapper->type->value()) {. I tried changingcommerce_producttocommerce_sampler, tried your original code, etc.I'm not very proficient with PHP yet, unfortunately.
Comment #19
brephraim commentedOK, well I guess let me back up: does this line item still refer to a product? I had assumed that was the case, otherwise the code will for sure not work.
Comment #20
mrpeanut commentedOh, yes, it does. But the product type machine name is sampler, although it is still a product. And then my custom line item (via Commerce Customizable Products) is sampler-pack.
Comment #21
brephraim commentedI modified the code in my original reply to your question. As I was saying, your columns might be off, but at least it should show up, and you can copy the $rows array code from the code already in your module as I described.
Comment #22
mrpeanut commentedStill no luck. This is my code (from #17, removed your rows array code and replaced it with the rows array code from the existing module).
Comment #23
mrpeanut commentedAhh, yes, I'm partially an idiot. The machine name is actually sampler_pack not sampler-pack. You're right, the columns are messed up, but the data is there. Now if I could just find a way to show the product display title in addition. :) Thank you!
Comment #24
brephraim commentedIt should be fairly simple to rearrange the code so the columns display as needed.
As for the product display title, that's probably going to be be a tougher nut to crack.
Comment #25
andyg5000As a heads up, I've renamed this "module" to Commerce Extra Tokens and split the different invoice parts into their own tokens. This allows for it to be used with more than just Commerce Email. Since Commerce Kickstart uses the message notify module, this will hopefully help more people who are trying to send detailed line items in their order emails. There are examples of how to use it with commerce_email and message_notify on this page http://drupal.org/sandbox/andyg5000/1532508 .
Comment #26
mengi commentedThank you for all your work, I would love to see this as a module or integrated with Commerce Email.
Comment #27
camizzz commentedGreat work!
i've a question.
Is it possible to print a field included into a line item types?
ex: line item type -> product -> field_customization
I would like to include in the order email the details of the customer customization.
the customizations are inserted with the Commerce Customizable Products module.
I hope you can help me!
greetings from italy :)
Comment #28
mrpeanut commented@camizzz -- Did you find a way to insert the field data from a Commerce Customizable Products field? Trying to do the same thing.
Comment #29
mrpeanut commented@camizzz — Not sure if you saw this, but a similar question exists at #1895022: Can you show a code example of how to access custom line item values in code?. I've tried changing the code from #22 to below, with no luck:
Comment #30
camizzz commented@MrPeanut - thanks for your help! I've found a way to output the field into the email, but it works only for input textfield. if i try to put in a field type "Term reference" which widget is Select list/Check boxes/radio buttons, I've got this error:
RECOVERABLE FATAL ERROR: OBJECT OF CLASS STDCLASS COULD NOT BE CONVERTED TO STRING IN _THEME_TABLE_CELL()
i would like to output the "names" of the taxonomy terms.
This works perfectly for input field
Thanks
Cami
Comment #31
mrpeanut commentedI just accomplished the same exact thing (with taxonomy term names). My field name is field_flavor.
$flavor = $line_item_wrapper->field_flavor->value();then$flavor->name(if I remember correctly, I can check my code if that doesn't work).Comment #32
camizzz commented@MrPeanut - Thank you! It works perfectly!
Comment #33
camizzz commented$line_item_wrapper->MY_FIELD->value()->name; works correctly only for select and radio buttons but not for Check Boxes. this is not strange? there is another way?
is there a reference page where can i find all kind of values?
ex: value()->name , value()->VALUE HERE
Thanks,
Cami
Comment #34
andyg5000Cami,
Inspect the wrapper object with $line_item_wrapper->getPropertyInfo(); You can run that through dpm (devel module) or var_dump/print_r and it will show you the properties within the $line_item_wrapper object. Then you'll know which property is available for use. I always suggest checking the existance of the field before attempting to access the value(). For example:
Hopefully this helps!
-A
Comment #35
camizzz commentedmaybe this is the moment to learn how to use devel module. I've no idea how to use your explanation. Currently to check that the value is outputted, i create the order and i check the sent email. I know, maybe this isn't the right way to work.
Can you explain me how and where insert $line_item_wrapper->getPropertyInfo(); ?
Thank you!
Comment #36
shaneonabike commentedAmazing!
Comment #37
zpolgar commentedI tried to use payment methods token in e-mail, but there is only the token name what I see in the mail.
Comment #38
zpolgar commentedThe payment method token not work separately, with the other tokens its ok.
Comment #39
zpolgar commentedMy problem is that the line items not show the discounted price. In the cart and during the checkout process I use discounted price for a line item but in the email I send the original price. Its a little bit confused. What can i do?
Comment #40
kevster commented@MrPeanut - did you ever get the shipping included in the summary totals belwo sub total? I managed to do this by changing commerce_extra_tokens.module around line 125 add another elseif:
This works for me and I just hide the previous shipping code that puts the shipping in inc VAT above the totals. Only thing I cant do now is change the weighting as the shipping appears below the VAT. Any ideas @andyg5000 on how to change the weighting to move shipping above the VAT?
Comment #41
janamills commentedperfect thanks! :-)
Comment #42
johnpitcairn commentedNote that now the patch from #1332698: Allow theming of [commerce-order:commerce-email-order-items] has been committed, the [commerce-email:commerce-email-order-items] table can be completely overridden in a new theme function,
theme_commerce_email_order_items(). The full $order entity is supplied as a variable, and you can generate line-items/product/shipping/etc from that.So it is now also possible to achieve just about anything you want using the standard token and a theme override.
Comment #43
waltercat commentedFor those of us who don't know how to theme and create modules, how can we edit the line item table? I have been able to use htmlmail to override the template, but other than that, I have no clue how to begin changing the template. I tried reviewing this issue as well as these two issues, but they all link and refer to one another but I can't figure out what exactly to do to override the line item table.
https://drupal.org/node/1332698
https://drupal.org/node/1605586
Comment #44
Motlem commentedThis module is working great for me, but I have one issue that I have not been able to overcome. I have a custom field in the line item that stores an integer value. I am able to get it to display just fine in the table, but I would like to sort the array by this value. I'm sure I'm probably missing something simple, but if someone knows how to resort this, I would appreciate the help.
I have:
and would like to be able to sort this by the $shelf value. My gratitude to anyone that can provide some assistance.
Comment #45
Zoltan Komar commentedHi!
I'm trying to create a new site wich uses this modul but there's one small problem wich i can't seem to figure out. I can't render the pizza toppings in a notification e-mail. The Toppings part is a field item but i can't render the field item in notification.As it seems its missing something i just can't figure it out. I tried all different methods from this and all other forums none of it works. I hope someone can help me.
Thanks in advance!
Comment #46
rszrama commented