Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

Displaying Membership of the User in Invoice

 
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)
 
Thread Tools Search this Thread
  #1  
Old 01-19-2020, 05:20 PM
 
siddharth.puri@wheelandba siddharth.puri@wheelandba is offline
 

Advanced Member
  
Join Date: Nov 2019
Posts: 66
 

Default 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
__________________
Version 5.3.6.6
Reply With Quote
  #2  
Old 01-20-2020, 05:43 AM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,190
 

Default 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.
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote

The following user thanks cflsystems for this useful post:
  #3  
Old 01-28-2020, 03:16 PM
 
siddharth.puri@wheelandba siddharth.puri@wheelandba is offline
 

Advanced Member
  
Join Date: Nov 2019
Posts: 66
 

Default Re: Displaying Membership of the User in Invoice

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
Attached Thumbnails
Click image for larger version

Name:	Adding Membership Name.PNG
Views:	255
Size:	24.2 KB
ID:	5438  
__________________
Version 5.3.6.6
Reply With Quote
  #4  
Old 01-28-2020, 04:14 PM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,190
 

Default 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
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote
  #5  
Old 01-28-2020, 05:12 PM
 
siddharth.puri@wheelandba siddharth.puri@wheelandba is offline
 

Advanced Member
  
Join Date: Nov 2019
Posts: 66
 

Default 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.
__________________
Version 5.3.6.6
Reply With Quote
  #6  
Old 01-28-2020, 05:39 PM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,190
 

Default Re: Displaying Membership of the User in Invoice

In that case refer to post #2 above
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote
  #7  
Old 02-18-2020, 07:53 PM
 
siddharth.puri@wheelandba siddharth.puri@wheelandba is offline
 

Advanced Member
  
Join Date: Nov 2019
Posts: 66
 

Default 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
__________________
Version 5.3.6.6
Reply With Quote
  #8  
Old 02-24-2020, 02:53 AM
 
memoto memoto is offline
 

X-Cart team
  
Join Date: Feb 2018
Posts: 246
 

Default 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
__________________
X-Cart Team
Reply With Quote

The following user thanks memoto for this useful post:
  #9  
Old 02-27-2020, 05:51 PM
 
siddharth.puri@wheelandba siddharth.puri@wheelandba is offline
 

Advanced Member
  
Join Date: Nov 2019
Posts: 66
 

Default 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.
__________________
Version 5.3.6.6
Reply With Quote
  #10  
Old 02-28-2020, 05:18 AM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,190
 

Default 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.
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote

The following user thanks cflsystems for this useful post:
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 01:22 PM.

   

 
X-Cart forums © 2001-2020