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)
-   -   How to link out-of-stock or low-stock items to admin end? (https://forum.x-cart.com/showthread.php?t=78234)

john.hodson@iinet.net.au 05-07-2021 02:07 AM

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

cflsystems 05-07-2021 05:13 AM

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

john.hodson@iinet.net.au 05-08-2021 12:09 AM

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.hodson@iinet.net.au 05-09-2021 04:37 PM

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

pauldodman 05-10-2021 01:41 AM

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>



john.hodson@iinet.net.au 05-10-2021 03:11 AM

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


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

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