Mabdatory coupon field in virtuemart


  • Your avatar
    seyi    
     5 years ago
    0

    Is there way to make the coupon field in virtuemart show cart page, a required field?
  • Your avatar
    seyi    
     5 years ago
    0

    In the past, I have done this by not showing the checkout button until a coupon is selected. You can check to see if the $_SESSION['coupon_code'] is populated, and if not do not show the checkout button. You would have to investigate what template file in Virtuemart the checkout button exists.
  • Default avatar
    dtws2008    
     5 years ago
    0

    Thanks a lot.
  • Default avatar
    dragana    
     4 years ago
    0

    I am also interested in making coupon filed mandatory, but I am not sure that I understood what which code to put in order to hide the checkout button.
    I found the template file with checkout button

    <?php
    if( !defined'_VALID_MOS' ) && !defined'_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' );
    /**
    *
    * @version $Id: shop.cart.tpl.php 1712 2009-03-30 07:38:09Z Aravot $
    * @package VirtueMart
    * @subpackage themes
    * @copyright Copyright (C) 2004-2008 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
    */
    mm_showMyFileName__FILE__ );

    echo 
    '<h2>'$VM_LANG->_('PHPSHOP_CART_TITLE') .'</h2>
    <!-- Cart Begins here -->
    '
    ;
    include(
    PAGEPATH'basket.php');
    echo 
    $basket_html;
    echo 
    '<!-- End Cart -->
    '
    ;
    // show Continue Shopping link when the cart is empty 
    if ($cart["idx"] == 0) {
        
    ?>
        <?php
          
    if( $continue_link != '') {
           
    ?>
            <a href="<?php echo $continue_link ?>" class="continue_link continue_link2">
           <?php echo $VM_LANG->_('PHPSHOP_CONTINUE_SHOPPING'); ?>
            </a>
           <?php
        
    }
        else {
          
    $continue_link=$sess->url($_SERVER['PHP_SELF'].'?option=com_virtuemart' ); 
        
    ?>
        <a href="<?php echo $continue_link ?>" class="continue_link">
        <?php echo $VM_LANG->_('PHPSHOP_CONTINUE_SHOPPING'); ?>
        </a>
        <?php
        
    }
    }
    // end Continue Shopping link    

    if ($cart["idx"]) {
        
    ?>
        <div class="vm_checkout_links">
        <hr />
        <?php
        
    if( $continue_link != '') {
            
    ?>
             <a href="<?php echo $continue_link ?>" class="continue_link">
                 <?php echo $VM_LANG->_('PHPSHOP_CONTINUE_SHOPPING'); ?>
             </a>
            <?php
        
    }
            
       if (!
    defined('_MIN_POV_REACHED')) { ?>

           <span style="font-weight:bold;"><?php echo $VM_LANG->_('PHPSHOP_CHECKOUT_ERR_MIN_POV2') . " ".$CURRENCY_DISPLAY->getFullValue($_SESSION['minimum_pov']) ?></span>
           <?php
       
    }
       else {
               
    $href $sess->url$_SERVER['PHP_SELF'].'?page=checkout.index&ssl_redirect=1'true);
               
    $href2 $sess->url$mm_action_url "/index2.php?page=checkout.index&ssl_redirect=1"true);
               
    $class_att 'class="checkout_link"';
               
    $text $VM_LANG->_('PHPSHOP_CHECKOUT_TITLE');
             
               if( 
    $this->get_cfg('useGreyBoxOnCheckout'1)) {
                   echo 
    vmCommonHTML::getGreyBoxPopupLink$href2$text''$text$class_att500600$href );
               }
               else {
                   
    ?>
                <a href="<?php echo $href ?>"><span class="round"><span><?php echo $text ?></span></span></a>
             
                
           <?php    }
         }
        
    ?>
        </div>
        
        <?php
        
    // End if statement
    }
    ?>


    Any help would be apprecieted! thanks
  • Your avatar
    seyi    
     4 years ago
    0

    in the section for checkout you could change

    <?php
       
    else {
               
    $href $sess->url$_SERVER['PHP_SELF'].'?page=checkout.index&ssl_redirect=1'true);
    ?>


    to something like this
    <?php
       
    elseif(!empty($_SESSION['coupon_code'])) {
               
    $href $sess->url$_SERVER['PHP_SELF'].'?page=checkout.index&ssl_redirect=1'true);
    ?>

  • Default avatar
    dragana    
     4 years ago
    0

    Thank you so much Seyi!
    Your hack works!
    Now, my problem is that if the same user tries to order something else, the coupon field is not mandatory anymore. (I am making a shop where users can by ONLY with coupons).
    I know that it has to do with session, I tried to put session_destroy(), but, as I am not familiar with php, I don't know where to place it or even if it's right code..
  • Your avatar
    seyi    
     4 years ago
    0

    the coupon code is stored in the user's session, this may be of help:
    http://awodev.com/forum/awocoupon/help-section/coupon-still-there-when-item-deleted