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

Override XCart class from Includes folder?

 
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)
 
Thread Tools Search this Thread
  #1  
Old 03-25-2016, 06:32 AM
 
Joel Erickson Joel Erickson is offline
 

Newbie
  
Join Date: Mar 2016
Posts: 5
 

Default Override XCart class from Includes folder?

I have learned how to add module classes to override and/or depend on other modules and the classes in the classes/XLite directory, per the instructions in the knowledge base:
http://kb.x-cart.com/display/XDD/Step+3+-+applying+logic+changes
http://kb.x-cart.com/display/XDD/Making+one+module+depend+on+another+one+--+creating+a+menu+in+the+customer+area

For example, I have successfully overridden \XLite\View functionality such as:
PHP Code:
namespace XLite\Module\MB\Override\View\ItemsList\Product\Customer;

abstract class 
ACustomer extends \XLite\View\ItemsList\Product\Customer\ACustomer implements \XLite\Base\IDecorator
{
    
/**
     * Return true if quick-look is enabled on the items list
     *
     * @return boolean
     */
    
protected function isQuickLookEnabled()
    {
        return 
false;
    }


However, I have not been able to figure out how to override classes in the Includes/Utils directory. For example, I have tried something like this:

PHP Code:
namespace XLite\Module\MB\Override\Includes\Utils;

abstract class 
Converter extends \Includes\Utils\Converter implements \XLite\Base\IDecorator
{
    public static function 
buildURL($target ''$action '', array $params = array(), $interface null)
    {
        
$result strval($interface);
        
$urlParams = array();

        if (!empty(
$target)) {
            
$urlParams['target'] = $target;
        }

        if (!empty(
$action)) {
            
$urlParams['action'] = $action;
        }

        
$params $urlParams $params;

        if (!empty(
$params)) {
            
$result .= '?' http_build_query($params'''&');
        }

        if (
$interface == 'cart.php') {
            
$result .= '#testing'// <--------- no effect yet
        
}
        return 
$result;
    }


But it has no effect on the storefront, so this class function is apparently not being called.
__________________
X-Cart Business 5.2.13
Reply With Quote
  #2  
Old 03-28-2016, 06:17 AM
  seyfin's Avatar 
seyfin seyfin is offline
 

X-Cart team
  
Join Date: May 2004
Posts: 1,223
 

Default Re: Override XCart class from Includes folder?

Could you please explain in details what customization you are trying to implement?
__________________
Sincerely yours,
Sergey Fomin
X-Cart team
Chief support group engineer

===

Check this out. Totally revamped X-Cart hosting
http://www.x-cart.com/hosting.html

Follow us:
https://twitter.com/x_cart / https://www.facebook.com/xcart / https://www.instagram.com/xcart
Reply With Quote
  #3  
Old 03-28-2016, 10:14 AM
 
Joel Erickson Joel Erickson is offline
 

Newbie
  
Join Date: Mar 2016
Posts: 5
 

Default Re: Override XCart class from Includes folder?

I'm trying to modify the storefront url structure, as the default cleanUrl feature doesn't suit my needs. I've managed to created a working solution by hacking the \Includes\Utils\Converter class function buildURL() itself, but I figured a more sustainable approach should be to try to override the function.

Now I see that function is only directly called from \XLite\Core\Converter.php, so I'll try overwriting that class.
__________________
X-Cart Business 5.2.13
Reply With Quote
  #4  
Old 03-31-2016, 03:27 AM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

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

Default Re: Override XCart class from Includes folder?

XC5 allows you to "decorate" classes in the "classes" directory only. You're right - it doesn't work with classes inside the Includes directory.

The \XLite\Core\Converter class will likely work in your case.
__________________
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
  #5  
Old 03-31-2016, 05:00 AM
 
Joel Erickson Joel Erickson is offline
 

Newbie
  
Join Date: Mar 2016
Posts: 5
 

Default Re: Override XCart class from Includes folder?

Yes, thanks, decorating that class did the trick.
__________________
X-Cart Business 5.2.13
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 02:33 AM.

   

 
X-Cart forums © 2001-2020