Update and Version 1.1.5


  • Default avatar
    MAD King    
     13 years ago
    0

    Hello,

    how do I update from version 1.0.0 to 1.0.2 and is it working with the lates VM version 1.1.5?

    Thx
  • Your avatar
    seyi    
     13 years ago
    0

    Update is the same process as installation, in the admin section through extensions->install/uninstall.

    And yes, AwoCoupon works fine with 1.1.5.
  • Default avatar
    MAD King    
     13 years ago
    0

    Thank you
  • Default avatar
    james_vir    
     13 years ago
    0

    Hi,

    Not sure if I did something wrong but I can't get awo to work with 1.1.5. I upgrade to 1.1.5, tested the component and it was not working. I then reinstalled it and still nothing....any suggestions?

    Thanks.
  • Your avatar
    seyi    
     13 years ago
    0

    There is a piece of code AwoCoupon inserts into virtuemart in order for AwoCoupon to work within it, and it probably got deleted when you upgraded to the new version. For the pro version, you just need to go to the AwoCoupon dashbord->installation and reinstall the codes. For the free version you have 2 options, i recommend the second.

    1) Uninstall and then reinstall AwoCoupon. Uninstalling will delete any coupon codes you have created within AwoCoupon.
    2) Follow the instructions here: https://awodev.com/documentation/awocoupon-virtuemart#Installation-2

    That should fix the problem.
  • Default avatar
    james_vir    
     13 years ago
    0

    I upgraded to the PRO, unstalled the free version...installed the pro and have checked the ps_coupon and what you mentioned is there...I have copied my ps_coupon


    <?php
    if( !defined'_VALID_MOS' ) && !defined'_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' );
    /**
    *
    * @version $Id: ps_coupon.php 1384 2008-04-22 19:53:11Z soeren_nb $
    * @package VirtueMart
    * @subpackage classes
    * @copyright Copyright (C) 2004-2007 soeren - All rights reserved.
    * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
    * VirtueMart is free software. This version may have been modified pursuant
    * to the GNU General Public License, and as distributed it includes or
    * is derivative of works licensed under the GNU General Public License or
    * other free or open source software licenses.
    * See /administrator/components/com_virtuemart/COPYRIGHT.php for copyright notices and details.
    *
    * http://virtuemart.net
    */

    /**
     * Class Code for coupon codes
     * The author would like to thank Digitally Imported (www.di.fm) for good music to code to
     *
     *
     * CHANGELOG:
     *
     * v 1.0: Initial Release (28-NOV-2004) - Erich
    */

    class ps_coupon {

        function 
    validate_add( &$d ) {
            global 
    $VM_LANG$vmLogger;
            
    /* init the database */
            
    $coupon_db =& new ps_DB;
            
    $valid true;
            
            
    /* make sure the coupon_code does not exist */
            
    $q "SELECT coupon_code FROM #__{vm}_coupons WHERE coupon_code = '".$coupon_db->getEscaped($d['coupon_code'])."' ";
            
    $coupon_db->query($q);
            if (
    $coupon_db->next_record()) {
                
    $vmLogger->err$VM_LANG->_('PHPSHOP_COUPON_CODE_EXISTS',false) );
                
    $valid false;
            }
            if( empty( 
    $d['coupon_value'] ) || empty( $d['coupon_code'] )) {
                
    $vmLogger->warning$VM_LANG->_('PHPSHOP_COUPON_COMPLETE_ALL_FIELDS',false) );
                
    $valid false;
            }
            if( !
    is_numeric$d['coupon_value'] )) {
                
    $vmLogger->err$VM_LANG->_('PHPSHOP_COUPON_VALUE_NOT_NUMBER',false) );
                
    $valid false;
            }
            return 
    $valid;
            
        }
        function 
    validate_update( &$d ) {
            global 
    $VM_LANG$vmLogger;
            
    /* init the database */
            
    $coupon_db =& new ps_DB;
            
    $valid true;
            
            
    /* make sure the coupon_code does not exist */
            
    $q "SELECT coupon_code FROM #__{vm}_coupons WHERE coupon_code = '".$coupon_db->getEscaped($d['coupon_code'])."' AND coupon_id <> '".$d['coupon_id']."'";
            
    $coupon_db->query($q);
            if (
    $coupon_db->next_record()) {
                
    $vmLogger->err$VM_LANG->_('PHPSHOP_COUPON_CODE_EXISTS',false) );
                
    $valid false;
            }
            if( empty( 
    $d['coupon_value'] ) || empty( $d['coupon_code'] )) {
                
    $vmLogger->err$VM_LANG->_('PHPSHOP_COUPON_COMPLETE_ALL_FIELDS',false) );
                
    $valid false;
            }
            if( !
    is_numeric$d['coupon_value'] )) {
                
    $vmLogger->err$VM_LANG->_('PHPSHOP_COUPON_VALUE_NOT_NUMBER',false) );
                
    $valid false;
            }
            return 
    $valid;
            
        }
        
    /* function to add a coupon coupon_code to the database */
        
    function add_coupon_code( &$d ) {
             global 
    $vmLogger$VM_LANG;
            
    $coupon_db =& new ps_DB;

            if( !
    $this->validate_add$d ) ) {
                return 
    false;
            }
            
    $fields = array(
                                
    'coupon_code' => vmGet($d,'coupon_code'),
                                
    'percent_or_total' => strtolower($d['percent_or_total']) == 'percent' 'percent' 'total',
                                
    'coupon_type' => strtolower($d['coupon_type']) == 'gift' 'gift' 'permanent',
                                
    'coupon_value' => (float)$d['coupon_value']
                            );
            
    $coupon_db->buildQuery'INSERT''#__{vm}_coupons'$fields );
            if( 
    $coupon_db->query() ) {
                
    $_REQUEST['coupon_id'] = $coupon_db->last_insert_id();
                
    $vmLogger->info($VM_LANG->_('VM_COUPON_ADDED'));
                return 
    true;
            }
            return 
    false;
         
        }
        
        
        
    /* $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ */
        
        /* function to update a coupon */
        
    function update_coupon( &$d ) {
              global 
    $vmLogger$VM_LANG;
            if( !
    $this->validate_update$d ) ) {
                return 
    false;
            }  
            
    /* init the database */
            
    $coupon_db = new ps_DB;
            
            
    $fields = array(
                                
    'coupon_code' => vmGet($d,'coupon_code'),
                                
    'percent_or_total' => strtolower($d['percent_or_total']) == 'percent' 'percent' 'total',
                                
    'coupon_type' => strtolower($d['coupon_type']) == 'gift' 'gift' 'permanent',
                                
    'coupon_value' => (float)$d['coupon_value']
                            );
            
    $coupon_db->buildQuery'UPDATE''#__{vm}_coupons'$fields'WHERE coupon_id = '.(int)$d['coupon_id'] );
            if( 
    $coupon_db->query() ) {
                
    $_REQUEST['coupon_id'] = $coupon_db->last_insert_id();
                
    $vmLogger->info($VM_LANG->_('VM_COUPON_UPDATED'));
                return 
    true;
            }
            return 
    false;
        }
        
            
        
    /* $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ */
        
        /* function to remove coupon coupon_code from the database */
        
    function remove_coupon_code( &$d ) {
            
            return require_once (
    JPATH_ADMINISTRATOR.DS."components".DS."com_awocoupon".DS."assets".DS."virtuemart".DS."ps_coupon_remove.php");
        }
        function 
    remove_coupon_code_vm( &$d ) {
            
    /* remove the coupon coupon_code */
            /* init the database */
            
    $coupon_db = new ps_DB;
            if( 
    is_array($d['coupon_id'] )) {
                foreach( 
    $d['coupon_id'] as $coupon ) {
                    
    $q 'DELETE FROM #__{vm}_coupons WHERE coupon_id = '.(int)$coupon;
                    
    $coupon_db->query($q);            
                }
            }
            else {
                
    $q 'DELETE FROM #__{vm}_coupons WHERE coupon_id = '.(int)$d['coupon_id'];
                
    $coupon_db->query($q);
            }
            
    $_SESSION['coupon_discount'] =    0;
            
    $_SESSION['coupon_redeemed']   = false;
            
            return 
    true;
        }
        
        
        
    /* function to process a coupon_code entered by a user */ 
        
    function process_coupon_code$d ) {
            return require_once (
    JPATH_ADMINISTRATOR.DS."components".DS."com_awocoupon".DS."assets".DS."virtuemart".DS."ps_coupon_process.php");
        }
        function 
    process_coupon_code_vm$d ) {
            global 
    $VM_LANG$vmLogger;
            
    /* init the database */
            
    $coupon_db =& new ps_DB;
            
            
    /* we need some functions from the checkout module */
            
    require_once( CLASSPATH "ps_checkout.php" );
            
    $checkout =& new ps_checkout();
            if( empty( 
    $d['total'])) {
                
    $totals $checkout->calc_order_totals($d);
                
    $d['total'] =     $totals['order_subtotal']
                                + 
    $totals['order_tax']
                                + 
    $totals['order_shipping']
                                + 
    $totals['order_shipping_tax']
                                - 
    $totals['payment_discount'];
            }
            
    $d['coupon_code'] = trim(vmGet$_REQUEST'coupon_code' ));
            
    $coupon_id vmGet$_SESSION'coupon_id'null );
            
            
    $q 'SELECT coupon_id, coupon_code, percent_or_total, coupon_value, coupon_type FROM #__{vm}_coupons WHERE ';
            if( 
    $coupon_id ) {
                
    /* the query to select the coupon coupon_code */
                
    $q .= 'coupon_id = '.intval($coupon_id);
            }
            else {
                
    /* the query to select the coupon coupon_code */
                
    $q .= 'coupon_code = \''.$coupon_db->getEscaped$d['coupon_code'] ).'\'';
            }
            
    /* make the query */
            
    $coupon_db->query($q);
            
            
    /* see if we have any fields returned */
            
    if ($coupon_db->num_rows() > 0)
            {
                
    /* we have a record */
                
                /* see if we are calculating percent or dollar discount */
                
    if ($coupon_db->f("percent_or_total") == "percent")
                {
                    
    /* percent */    
                    //$subtotal = $checkout->calc_order_subtotal( $d );
                    
                    /* take the subtotal for calculation of the discount */
                    //$_SESSION['coupon_discount'] = round( ($subtotal * $coupon_db->f("coupon_value") / 100), 2);
                     
    $coupon_value round( ($d["total"] * $coupon_db->f("coupon_value") / 100), 2);
                     
                     if( 
    $d["total"] < $coupon_value ) {
                          
    $coupon_value = (float)$d['total'];
                          
    $vmLogger->infostr_replace('{value}',$GLOBALS['CURRENCY_DISPLAY']->getFullValue$coupon_value ),$VM_LANG->_('VM_COUPON_GREATER_TOTAL_SETTO')) );
                    }
                     
    $_SESSION['coupon_discount'] = $coupon_value;
                }
                else
                {
                    
                    
    $coupon_value $coupon_db->f("coupon_value");

                    
    /* Total Amount */
                    
    if( $d["total"] < $coupon_value ) {
                          
    $coupon_value = (float)$d['total'];
                          
    $vmLogger->infostr_replace('{value}',$GLOBALS['CURRENCY_DISPLAY']->getFullValue$coupon_value ),$VM_LANG->_('VM_COUPON_GREATER_TOTAL_SETTO')) );
                    }
                    
    $_SESSION['coupon_discount'] = $GLOBALS['CURRENCY']->convert$coupon_value );
                    
                }
                
                
    /* mark this order as having used a coupon so people cant go and use coupons over and over */
                
    $_SESSION['coupon_redeemed'] = true;
                
    $_SESSION['coupon_id'] = $coupon_db->f("coupon_id");
                
    $_SESSION['coupon_code'] = $coupon_db->f("coupon_code");
                
    $_SESSION['coupon_type'] = $coupon_db->f("coupon_type");
                    
                
            }
            else
            {
                
    /* no record, so coupon_code entered was not valid */
                
    $GLOBALS['coupon_error'] = $VM_LANG->_('PHPSHOP_COUPON_CODE_INVALID');
                return 
    false;
                
            }
         
        }    
    }
      
    ?>

  • Your avatar
    seyi    
     13 years ago
    0

    can you specify what issues you are having? your ps_coupon.php file looks fine. In AwoCoupon, did you go to the dashboard->"Installation Check" page? Is everything installed?
  • Default avatar
    james_vir    
     13 years ago
    0

    The coupon box appears and once I enter a code it completely vanishes and does not apply the discount...is there a cache I should clean for something like this?

    edit: yes everything says installed in the config
  • Your avatar
    seyi    
     13 years ago
    0

    no, cache does not affect the front end. if the coupon box has disappeared it means that the coupon has been applied. do you have a public website where i could view this? you can send me a private message with details if you prefer.
  • Default avatar
    james_vir    
     13 years ago
    0

    I just emailed you the url.

    I appreciate the quick responses!

  • Default avatar
    james_vir    
     13 years ago
    0

    Problem ended being the . basket.php which i was tweaking before installing the coupon component. Just replaced it and now everything is fine.

    Awesome component and awesome support!!