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

Default Product Values

 
Closed Thread
   X-Cart forums > X-Cart 5 > General questions (X-Cart 5)
 
Thread Tools Search this Thread
  #21  
Old 12-11-2016, 10:18 PM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

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

Default Re: Default Product Values

Quote:
Originally Posted by superdave144
Ok I added the new module and enabled it. The Main.php is configured in /classes/XLite/Module/JRG/Quantity directory. I created the new product.php file in the /classes/XLite/Module/JRG/Quantity/Model/ directory. I redeployed the store after the module was created as well. The default quantity is still showing 1000. Do I need a reference from the Main.php to the product.php file?

You don't need a reference.
But did you enable your custom module on the Modules page in the back end?
Also, did you replace "DEV_ID" with "JRG", and "MODULE_ID" with "Quantity" in the module's source code?
You may also check if there is product.php file in the var/run/classes/XLite/Module/JRG/Quantity/Model/ directory and whether it is not empty.
__________________
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
  #22  
Old 12-12-2016, 06:31 AM
 
superdave144 superdave144 is offline
 

Advanced Member
  
Join Date: Sep 2015
Posts: 77
 

Default Re: Default Product Values

Here is the product.php file located in /opt/bitnami/apps/xcart/htdocs/classes/XLite/Module/JRG/Quantity/Model

// File: classes/XLite/Module/JRG/Quantity/Model/Product.php

namespace XLite\Module\JRG\Quantity\Model;

class Product extends \XLite\Model\Product implements \XLite\Base\IDecorator
{
/**
* Default qty value to show to customers
*
* @return integer
*/
public function getDefaultAmount()
{
return 1;
}
}


Here is the main.php file located in /opt/bitnami/apps/xcart/htdocs/classes/XLite/Module/JRG/Quantity

<?php
namespace XLite\Module\JRG\Quantity;

abstract class Main extends \XLite\Module\AModule
{
/**
* Just Retro Games
*
* @return string
*/
public static function getAuthorName()
{
return 'Just Retro Games';
}

/**
* Module name
*
* @return string
*/
public static function getModuleName()
{
return 'Default Item Quantity';
}

/**
* Get module major version
*
* @return string
*/
public static function getMajorVersion()
{
return '5.3';
}

/**
* Module version
*
* @return string
*/
public static function getMinorVersion()
{
return 0;
}

/**
* Module description
*
* @return string
*/
public static function getDescription()
{
return 'Sets the default item quantity to 1 instead of 1000';
}

There is no model subfolder in this directory. /opt/bitnami/apps/xcart/htdocs/var/run/classes/XLite/Module/JRG/Quantity
__________________
David
X-Cart Business 5.3.2.2
  #23  
Old 12-19-2016, 04:50 AM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

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

Default Re: Default Product Values

Quote:
Originally Posted by superdave144
There is no model subfolder in this directory. /opt/bitnami/apps/xcart/htdocs/var/run/classes/XLite/Module/JRG/Quantity

It sounds as you missed the "<?php" in the first line in that file, so XC5 doesn't consider this as a PHP script and ignores it.

Anyway, I've tried the code on my local installation and I see that overriding the method is not enough. You should also change \XLite\Model\Product::__constructor($data) as the $amount property is initialised with the constant, not with the value returned by the method. So, you should override it in the constructor as well.

Please check the attached custom module - it should work for you.
Attached Files
File Type: tar Custom-ForceDefaultQty-v5_3_0.tar (6.0 KB, 219 views)
__________________
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

The following user thanks qualiteam for this useful post:
superdave144 (12-20-2016)
  #24  
Old 12-20-2016, 05:31 AM
 
superdave144 superdave144 is offline
 

Advanced Member
  
Join Date: Sep 2015
Posts: 77
 

Default Re: Default Product Values

That worked! Thank you very much Alex!
__________________
David
X-Cart Business 5.3.2.2
Closed Thread
   X-Cart forums > X-Cart 5 > General 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 PM.

   

 
X-Cart forums © 2001-2020