View Single Post
  #4  
Old 09-04-2016, 08:25 PM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

X-Guru
  
Join Date: Dec 2010
Posts: 6,373
 

Default Re: Add to Cart Button for Out of Stock

The widget that displays the button on the product page and in the Quick Look popup is this one:
\XLite\View\Product\Details\Customer\AddButton

You can alter it as follows:

1. Create a custom template in your module (skins/default/en/modules/[YOUR_DEV_ID]/[YOUR_MODULE_ID]/product/add_button/body.tpl) with the following code (it is a slightly tweaked copy of the code from the skins/default/en/product/add_button/body.tpl file):
Code:
<div class="add-button-wrapper {getFingerprint()}"> <widget IF="!isOutOfStock()" class="\XLite\View\Button\Submit" label="{getButtonLabel()}" style="regular-main-button add2cart" /> </div>

2. Decorate the widget as follows:
PHP Code:
<?php
class AddButton extends \XLite\View\Product\Details\Customer\AddButton implements \XLite\Base\IDecorator
{
    protected function 
getButtonLabel()
    {
        return 
$this->isSpecialOrderButton() ? 'Special order' 'Add to cart';
    }

    protected function 
isSpecialOrderButton()
    {
        
$product $this->getProduct();
        
$result = ...place there your check against the product...

        return 
$result;
    }
}

You need also a way to configure which products are regular ones, and which should display the custom button label. Depending on this you should adjust the above text.

As for the popup message: do you mean the message that appears at the top of the page? If so, you should look into decorating the \XLite\Controller\Customer\Cart::doActionAdd() and other methods that it calls.

As you see this may require changing a number of files, so you may be better to hire someone who could code this for you.
__________________
Alex Solovev,
Qualiteam

---

User manual Video tutorials X-Cart FAQ

You are welcome to press "Thanks" button
if you find this post useful

Click here to learn how to apply patches

X-Cart Extensions
Reply With Quote