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

Argument 1 passed to must be an instance of ...\..\, string given

 
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)
 
Thread Tools Search this Thread
  #1  
Old 07-20-2017, 03:31 AM
 
ajeetsingh ajeetsingh is offline
 

Member
  
Join Date: Dec 2016
Posts: 28
 

Default Argument 1 passed to must be an instance of ...\..\, string given

Hello Anyone,

I have some issue in xcart 5.3.3.1 version to develop a module like pre order.

My code in preorder.php file are as below:

PHP Code:
public function getPreOrder(\XLite\Core\CommonCell $cnd null$value false)
{
   
$queryBuilder $this->createQueryBuilder('v');
   
$this->currentSearchCnd $cnd;       

   return 
$this->getPreorderItem($queryBuilder$value);


And that function is calling in another file name AddButton.php place as below:

PHP Code:
protected function getDefaultTemplate() {              
      
$product_id = \XLite\Core\Request::getInstance()->getData()['product_id'];       
      
$preorder_details = \XLite\Core\Database::getRepo('XLite\Module\Webkulsoftware\PreorderSales\Model\Preorders')->getPreOrder('',$product_id);
      
     if(
$preorder_details[0]->enabled)
        return 
'modules/Webkulsoftware/PreorderSales/add_button/body.twig';
      else
        return 
'product/add_button/body.twig';
    } 


And when i run that code the found an error on front-end product details page as below:

Argument 1 passed to XLite\Module\Webkulsoftware\PreorderSales\Model\Re po\Preorders::getPreOrder() must be an instance of XLite\Core\CommonCell, string given, called in /home/users/ajeetsingh/www/html/xcart5331/var/run/classes/XLite/Module/Webkulsoftware/PreorderSales/View/Product/Details/Customer/AddButton.php


So, Can any one suggest me that what i do wrong.I am waiting for a valuable suggestion.
__________________
Ajeet Singh
Sr.Software Developer
Webkul Software Pvt. Ltd.
Reply With Quote
  #2  
Old 07-20-2017, 05:46 AM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,020
 

Default Re: Argument 1 passed to must be an instance of ...\..\, string given

As the error states you are passing string while the function expects an object

PHP Code:
$preorder_details = \XLite\Core\Database::getRepo('XLite\Module\Webkulsoftware\PreorderSales\Model\Preorders')->getPreOrder('',$product_id); 


This should works

PHP Code:
$cnd = new \XLite\Core\CommonCell;

$preorder_details = \XLite\Core\Database::getRepo('XLite\Module\Webkulsoftware\PreorderSales\Model\Preorders')->getPreOrder($cnd,$product_id); 
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote

The following 2 users thank cflsystems for this useful post:
ajeetsingh (07-20-2017), qualiteam (07-24-2017)
  #3  
Old 07-20-2017, 07:12 AM
 
ajeetsingh ajeetsingh is offline
 

Member
  
Join Date: Dec 2016
Posts: 28
 

Default Re: Argument 1 passed to must be an instance of ...\..\, string given

Quote:
Originally Posted by cflsystems
As the error states you are passing string while the function expects an object

PHP Code:
$preorder_details = \XLite\Core\Database::getRepo('XLite\Module\Webkulsoftware\PreorderSales\Model\Preorders')->getPreOrder('',$product_id); 


This should works

PHP Code:
$cnd = new \XLite\Core\CommonCell;

$preorder_details = \XLite\Core\Database::getRepo('XLite\Module\Webkulsoftware\PreorderSales\Model\Preorders')->getPreOrder($cnd,$product_id); 


Thank you for a valuable reply. It's Work for me.
__________________
Ajeet Singh
Sr.Software Developer
Webkul Software Pvt. Ltd.
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 04:56 PM.

   

 
X-Cart forums © 2001-2020