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 > Modifying the design and features (X-Cart 5)
 
Thread Tools Search this Thread
  #11  
Old 03-01-2020, 03:48 PM
 
siddharth.puri@wheelandba siddharth.puri@wheelandba is online now
 

Advanced Member
  
Join Date: Nov 2019
Posts: 49
 

Default Re: Displaying Membership of the User in Invoice

Hi, Thanks for you help. I was able to display the membership when the order is completed and the invoice is generated (please see image attached).

However, I am still not able to display it in the email that is sent.
I even changed the list name an weight to list="invoice.items.head", weight="9" to display them above 'item list' in the invoice.
Is it possible to showcase it in the email sent to admin?

Thanks and Regards.
Attached Thumbnails
Click image for larger version

Name:	Capture.PNG
Views:	10
Size:	62.6 KB
ID:	5449  
__________________
Siddharth Puri
Version 5.3.6.1
Reply With Quote
  #12  
Old 03-01-2020, 04:37 PM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 13,810
 

Default Re: Displaying Membership of the User in Invoice

Quote:
Originally Posted by siddharth.puri@wheelandba
Is it possible to showcase it in the email sent to admin?




You can. You have to look at the mail class(es) for this particular case and see if whatever is made available to the mail template includes membership. If not you need to make it available to the mail template in order to include it within the email send from cart to admin and/or customer.



Mail classes are separate from the rest f the logic/views.
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote
  #13  
Old 03-01-2020, 05:46 PM
 
siddharth.puri@wheelandba siddharth.puri@wheelandba is online now
 

Advanced Member
  
Join Date: Nov 2019
Posts: 49
 

Default Re: Displaying Membership of the User in Invoice

Hi, So I suppose I have to make changes to the classes/xlite/view/mailer.php?

And how can I make membership available to this class?

Do I declare the function this.order.profile.membership.name here?

Thanks
__________________
Siddharth Puri
Version 5.3.6.1
Reply With Quote
  #14  
Old 03-02-2020, 12:36 AM
 
Ed B. Ed B. is offline
 

eXpert
  
Join Date: Apr 2016
Posts: 293
 

Default Re: Displaying Membership of the User in Invoice

Quote:
Originally Posted by siddharth.puri@wheelandba
Hi, So I suppose I have to make changes to the classes/xlite/view/mailer.php?

You would rather change classes/xlite/Core/Mailer.php, or classes/xlite/Core/Mail/AMail.php or classes/xlite/Core/Mail/Order/AOrder.php


Basically you would need to extend it to modify the function sendOrderWhatever(Order $order) and add to static::register() method the membership. )c.f. https://devs.x-cart.com/changing_store_logic/creating_custom_email_notifications.html

so that membership becomes available in appropriate twig files. However, probably you may get away with playing with the constructor in Core/Mail/AMail.php or Core/Mail/Order/AOrder.php
__________________
X-cart 5.2.12, php 5.6
Ed from Grenoble, France
Reply With Quote

The following user thanks Ed B. for this useful post:
  #15  
Old 03-02-2020, 03:09 PM
 
siddharth.puri@wheelandba siddharth.puri@wheelandba is online now
 

Advanced Member
  
Join Date: Nov 2019
Posts: 49
 

Default Re: Displaying Membership of the User in Invoice

Hi,

Looking at the example, I have an understanding that:

So If I am changing the function public static function sendOrderProcessedAdmin(\XLite\Model\Order $order)
{
static::register([
CODE TO REGISTER MEMBERSHIP HERE
]);

$result = static::composeOrderDepartmentMail('order_processe d', $order);

if ($result && !static::hasScheduledJob()) {
\XLite\Core\OrderHistory::getInstance()->registerAdminEmailSent(
$order->getOrderId(),
'Order is processed'
);

} elseif (static::$errorMessage) {
\XLite\Core\OrderHistory::getInstance()->registerAdminEmailFailed(
$order->getOrderId(),
static::$errorMessage
);
}
}

What needs to be entered to register membership function to make it available.

Thanks and Regards.
__________________
Siddharth Puri
Version 5.3.6.1
Reply With Quote
  #16  
Old 03-03-2020, 12:10 AM
 
Ed B. Ed B. is offline
 

eXpert
  
Join Date: Apr 2016
Posts: 293
 

Default Re: Displaying Membership of the User in Invoice

Something like
Code:
'membership' => $this->order->membership,
If "$this" doesn't have the property called membership, then you could try
Code:
'membership' =>\XLite\Core\Auth::getInstance()->getProfile()->membership,
__________________
X-cart 5.2.12, php 5.6
Ed from Grenoble, France
Reply With Quote
  #17  
Old 03-03-2020, 07:57 PM
 
siddharth.puri@wheelandba siddharth.puri@wheelandba is online now
 

Advanced Member
  
Join Date: Nov 2019
Posts: 49
 

Default Re: Displaying Membership of the User in Invoice

Hi,

Thanks for your assistance. Really appreciate it.

I changed the function to
public static function sendOrderProcessedAdmin(\XLite\Model\Order $order)
{

static::register([
'membership' =>\XLite\Core\Auth::getInstance()->getProfile()->membership,
]);

$result = static::composeOrderDepartmentMail('order_processe d', $order);

if ($result && !static::hasScheduledJob()) {
\XLite\Core\OrderHistory::getInstance()->registerAdminEmailSent(
$order->getOrderId(),
'Order is processed'
);

} elseif (static::$errorMessage) {
\XLite\Core\OrderHistory::getInstance()->registerAdminEmailFailed(
$order->getOrderId(),
static::$errorMessage
);
}
}
"$this" doesn't have the property called membership so that won't work as well.


However, I still don't see the membership name in the email sent to admin when order is processed.


I am using {{ this.order.profile.membership.name }} in the view to showcase the membership name. Does that define the way we register the membership in the sendOrderProcessed Function?

Kind Regrads,
Siddharth Puri
__________________
Siddharth Puri
Version 5.3.6.1
Reply With Quote
  #18  
Old 03-05-2020, 12:12 AM
 
Ed B. Ed B. is offline
 

eXpert
  
Join Date: Apr 2016
Posts: 293
 

Default Re: Displaying Membership of the User in Invoice

Since you have registered membership for the class, {{this.membership.name}} should do, if I understand correctly xc documentation (and its content is up to date/correct).
__________________
X-cart 5.2.12, php 5.6
Ed from Grenoble, France
Reply With Quote
  #19  
Old 03-05-2020, 06:37 PM
 
siddharth.puri@wheelandba siddharth.puri@wheelandba is online now
 

Advanced Member
  
Join Date: Nov 2019
Posts: 49
 

Default Re: Displaying Membership of the User in Invoice

Hi finally, I could do it. I went back to the simple solution and added
<div>{{ this.order.profile.membership.name }}</div> to the skins/common/order/invoice/parts/head.twig and it displays. i don't know why did did not work in the note.twig. Thank you everyone for their awesome support.



{##
# Invoice head
#
# @ListChild (list="invoice.base", weight="10")
#}
<table cellspacing="0" class="header">
<tr>
{{ widget_list('invoice.head') }}
</tr>
<tr>
<div>{{ this.order.profile.membership.name }}</div>
</tr>
</table>


Kind Regards
__________________
Siddharth Puri
Version 5.3.6.1
Reply With Quote
Reply
   X-Cart forums > X-Cart 5 > Modifying the design and features (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 06:08 AM.

   

 
X-Cart forums © 2001-2020