X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (X-Cart 5) (https://forum.x-cart.com/forumdisplay.php?f=56)
-   -   Displaying Membership of the User in Invoice (https://forum.x-cart.com/showthread.php?t=77529)

siddharth.puri@wheelandba 01-19-2020 05:20 PM

Displaying Membership of the User in Invoice
 
Hi, How can I display the membership of user in the invoice? Just need to figure out how to grab the membership of the user and I will add that to the email notification.


Thanks and Regards,
Siddharth Puri

cflsystems 01-20-2020 05:43 AM

Re: Displaying Membership of the User in Invoice
 
You need to create custom module for this, best option, and add new template file to the invoice. You can position it by using @ListChild in the doc block at the beginning of the file. Just see how other templates are done.

This is a quick dirty hack. Using customer/order/invoice/parts/note.twig (and you can do that too with the theme_tweaker) if I add at the end of it


Code:

{{ this.order.profile.membership.name }}


it will show the membership name. Keep in mind this is the membership at the time of order. Changing the membership of the customer later will not affect this order's profile.
If you want to grab the current profile membership regardless of order use


Code:

{{ this.order.origProfile.membership.name }}


Also neither one will show name if there is no membership assigned to the profile in question.

siddharth.puri@wheelandba 01-28-2020 03:16 PM

Re: Displaying Membership of the User in Invoice
 
1 Attachment(s)
Hi, I added the code {{ this.order.profile.membership.name }} to the template as you suggested. (Please see image attached)

However, I do not see the membership info on the invoice even for customers who have a membership.

Please have a look.

Thanks and Regards,
Siddharth Puri

cflsystems 01-28-2020 04:14 PM

Re: Displaying Membership of the User in Invoice
 
You added it inside the "if" statement for the notes. So if the order has no customer notes nothing will show. You have to add it outside the conditional statement

siddharth.puri@wheelandba 01-28-2020 05:12 PM

Re: Displaying Membership of the User in Invoice
 
Hi I changed it now to
{##
# Order customer note
#
# @ListChild (list="invoice.base", weight="40")
#}

{% if this.order.getNotes() %}
<div class="customer-note">
<h3>{{ t('Customer note') }}:</h3>
<div>{{ this.order.getNotes()|nl2br }}</div>
</div>
{% endif %}

<div>{{ this.order.profile.membership.name }}</div>



However, still no membership is displayed.

cflsystems 01-28-2020 05:39 PM

Re: Displaying Membership of the User in Invoice
 
In that case refer to post #2 above

siddharth.puri@wheelandba 02-18-2020 07:53 PM

Re: Displaying Membership of the User in Invoice
 
Hi,

I installed a new module. How can I add template files to it? Can you please guide me in the next step.

Thanks and Regards,
Siddharth P

memoto 02-24-2020 02:53 AM

Re: Displaying Membership of the User in Invoice
 
Check the following article on how to implement template usage into the module: https://devs.x-cart.com/getting_started/how-to-apply-design-changes.html#module-pack

siddharth.puri@wheelandba 02-27-2020 05:51 PM

Re: Displaying Membership of the User in Invoice
 
Hi, I am just starting with Xcart. So I am not really confident. Do you have any example I can follow.
I assume I have to add the template file with the code <div>{{ this.order.profile.membership.name }}</div> and add that via list view to invoice.
So according to the example I have to add code
{##
#Order customer note
#
# @ListChild (list="invoice.base", weight="39")
#}
<div>{{ this.order.profile.membership.name }}</div>

However, I am not sure about the process.

Any help will be really appreciated.

cflsystems 02-28-2020 05:18 AM

Re: Displaying Membership of the User in Invoice
 
The ListChild tells the rebuild process where to inject the content of the template.
In this case it is in list "invoice.base'. So the content of your new template will show alongside with all other templates that belong to that same list.
The "weight" parameter tells the rebuild process where in the the stack within this list to inject the template. In other words "weight" it's used for sorting - sorting is in ascending order, lower to higher number.

All you have to do is to have this template and include the ListChild line then rebuild the cart - from there the process automatically will pick up on that and do whatever needs to be done.

If you do not have the ListChild directive in the template you will have to have View class that shows the template and include it there (or without the list directive your template will show when the View class is called from some other template or class).


If you include the list directive in the template file you don;t even have to have a View class to support it unless you need to show info in the template that is not already available for that view - then you need View class to pass that info to the template.


All times are GMT -8. The time now is 03:31 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.