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

How to link out-of-stock or low-stock items to admin end?

 
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)
 
Thread Tools Search this Thread
  #1  
Old 05-07-2021, 02:07 AM
 
john.hodson@iinet.net.au john.hodson@iinet.net.au is offline
 

Advanced Member
  
Join Date: Apr 2008
Posts: 68
 

Default How to link out-of-stock or low-stock items to admin end?

Hi,

When we have items that are low in stock or out-of-stock, we can emails to let us know that that item is low or out of stock. In XC5.3, the email contains a link that took us to the Admin Back-end so we can update the quantity, delete, or disable the product. However, we just upgraded to XC5.4, and the link now takes us (unhelpfully) to the customer front-end.

What can we do to change it so that it can take us to Admin Back-end, just like how it was with XC5.3?

Thank you in advance.
John
__________________
John
XCart Business v.5.4.1.27
Reply With Quote
  #2  
Old 05-07-2021, 05:13 AM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,026
 

Default Re: How to link out-of-stock or low-stock items to admin end?

You can decorate classes/XLite/View/Product/MailBox.php class and modify

Code:
protected function getDefaultProductURLProcessor() { return function (Product $product) { return $this->buildFullURL('product', '', ['product_id' => $product->getId()]); }; }


or


Code:
protected function getProductURL() { $closure = $this->getProductURLProcessor(); return $closure($this->getProduct()); }


to return admin side url for the product. The way this is now it will almost always return the storefront url because the warning is usually called from the storefront due to product getting low stock after order placement.


You can decorate the getProductURL like this


Code:
/** * @return string */ protected function getProductURL() { return \XLite\Core\Converter::buildFullURL($target, $action, $params, \XLite::getAdminScript(), fasle, false); }


This is untested
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote
  #3  
Old 05-08-2021, 12:09 AM
 
john.hodson@iinet.net.au john.hodson@iinet.net.au is offline
 

Advanced Member
  
Join Date: Apr 2008
Posts: 68
 

Default Re: How to link out-of-stock or low-stock items to admin end?

Hi Steve,

Thank you for that. It is a pity that we don't know what the code is and where it resides in the XC5.3. That code could then be replicated in XC5.4.

We will keep looking. Thanks again.
Cheers,
John
__________________
John
XCart Business v.5.4.1.27
Reply With Quote
  #4  
Old 05-09-2021, 04:37 PM
 
john.hodson@iinet.net.au john.hodson@iinet.net.au is offline
 

Advanced Member
  
Join Date: Apr 2008
Posts: 68
 

Default Re: How to link out-of-stock or low-stock items to admin end?

Hi,

I'm told that the code that needs to be changed is in
/admin.php?target=theme_tweaker_template&template=m ail%2Fcommon%2Flow_limit_warning%2Fbody.twig&inter face=mail&innerInterface=admin (i.e. mail/common/low_limit_warning/body.twig).

Below is the current XC5.4 code that takes me to the customer front-end:

{{ widget('\\XLite\\View\\Product\\MailBox', product=this.product,
productUrlProcessor=this.product_url_processor, amount=this.amount) }}

Does anyone know how to change this code to take me to the Admin Back-End? (I'm totally ignorant of code-writing, sorry.)

Thank you in advance.
Cheers,
John
__________________
John
XCart Business v.5.4.1.27
Reply With Quote
  #5  
Old 05-10-2021, 01:41 AM
  pauldodman's Avatar 
pauldodman pauldodman is offline
 

X-Guru
  
Join Date: Jul 2003
Location: Spain / UK
Posts: 3,023
 

Default Re: How to link out-of-stock or low-stock items to admin end?

Don't know if this helps, but in 5.3, that same file looked like this:


Code:
{## # Low limit warning email body (to admin) #} <p> {{ t('SKU') }}: {{ this.product.sku|raw }}<br /> {{ t('Product name') }}: {{ this.product.name|raw }}<br /> <br /> {{ t('In stock') }}: {{ t('X items', {'count': this.product.amount}) }} </p> <p> {{ t('Click the link to increase product amount') }}: <a href="{{ this.product.adminURL }}">{{ this.product.adminURL }}</a> </p>
__________________
Paul Dodman
e-business & m-commerce consultant
w: www.luminointernet.com
e: xcart@luminointernet.com

Professional X-Cart help, advice, support and services, specialists in Mobile X-Cart.
Reply With Quote
  #6  
Old 05-10-2021, 03:11 AM
 
john.hodson@iinet.net.au john.hodson@iinet.net.au is offline
 

Advanced Member
  
Join Date: Apr 2008
Posts: 68
 

Default Re: How to link out-of-stock or low-stock items to admin end?

Hi Paul,

Thank you for that. It almost works as shown in the attached screenshot, but the link does not. But really appreciate your help anyhow.

Cheers,
John
Attached Thumbnails
Click image for larger version

Name:	Screen Shot 2021-05-10 at 9.08.18 pm.png
Views:	13
Size:	41.7 KB
ID:	5641  
__________________
John
XCart Business v.5.4.1.27
Reply With Quote
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 12:46 AM.

   

 
X-Cart forums © 2001-2020