select disabled category in coupon


  • Default avatar
    jeroenb    
     9 years ago
    0

    I created two categories which I want to use as a base for giving discount, one for discount_high and one for discount_low.
    These categories are not to be shown in my shop so I disabled them. But being disabled I cannot select them in the coupon.
    A option would be to add all induvidual products to the coupon, but with 300+ products this is very 'errorsensitive'.
    Do you have a solution for this?
  • Your avatar
    seyi    
     9 years ago
    0

    Hello,

    To display the unpublished categories, you would need to edit the code.

    in www/administrator/components/com_awocoupon/helpers/estore/virtuemart/helper.php, in these 2 functions:
    - categoryListTreeLoop
    - getEStoreCategory

    You will see

    c.published=1


    Change it to
    1=1


  • Default avatar
    jeroenb    
     9 years ago
    0

    Hi Seyi,

    is this correct?
    static function getEStoreCategory($category_id=null,$search=null,$limit=null,$limitstart=null,$orderby=null,$orderbydir=null) {
            if(empty($category_id) && empty($search) && empty($limit)) return self::categoryListTree();
            
            $db = JFactory::getDBO();

            $limit = (int)$limit;
            $limitstart = (int)$limitstart;
            if(!empty($orderbydir) && strtolower($orderbydir)!='asc' && strtolower($orderbydir!='desc')) $orderbydir = '';
            
            $sql = 'SELECT SQL_CALC_FOUND_ROWS c.virtuemart_category_id AS id,lang.category_name AS label
                      FROM #__virtuemart_categories c
                      JOIN `#__virtuemart_categories_'.self::getVMLang().'` as lang using (`virtuemart_category_id`)
                     //WHERE c.published=1
                     WHERE 1=1
                     '.(!empty($category_id) ? ' AND c.virtuemart_category_id IN ('.self::scrubids($category_id).') ' : '').'
                     '.(!empty($search) ? ' AND lang.category_name LIKE '.$db->Quote( '%'.awolibrary::dbEscape( trim(JString::strtolower( $search ) ), true ).'%', false ).' ' : '').' 
                     ORDER BY '.(empty($orderby) ? 'lang.category_name,c.virtuemart_category_id' : $orderby).' '.(!empty($orderbydir) ? $orderbydir : '').'
                     '.(!empty($limit) ? ' LIMIT '.(!empty($limitstart) ? $limitstart.',' : '').' '.(int)$limit.' ':'');
            $db->setQuery($sql);
            return $db->loadObjectList('id');
        }
        static private function categoryListTree($selectedCategories = array(), $cid = 0, $level = 0, $disabledFields=array()) {
            global $option;
            
            $cache = JFactory::getCache($option);
            $cache->setCaching( 1 );
            $cache->setLifeTime(version_compare( JVERSION, '1.6.0', 'ge' ) ? 300/60 : 300);
            //$rtn = $cache->call( array( 'AwocouponVirtuemartHelper', 'categoryListTreeLoop' ),$selectedCategories, $cid, $level, $disabledFields );
            $rtn = self::categoryListTreeLoop($selectedCategories, $cid, $level, $disabledFields);

            return $rtn;
        } 


    I did not find the c.published=1 in the categorylistTree function.

    regards,
    Jeroen
  • Your avatar
    seyi    
     9 years ago
    0

    No, that will give you a db error. Remove

    //WHERE c.published=1

    In categorylisttree, there is no published=1?
  • Default avatar
    jeroenb    
     9 years ago
    0

    I sent you the file in regular mail, maybe I am overlooking something.
  • Your avatar
    seyi    
     9 years ago
    0

    Hello,

    You do not really need that code any more. Upgrade to the latest, 2.3.4. The code is there, you just need to activate it.

    For this, you would have to update the awocoupon config table in the database. Here is the sql:

    INSERT INTO #__awocoupon_config (name,value) VALUES ('display_category_unpublished', 1);


    You would have to modify #_ to your actual prefix.