Exclude Gift Certificates from Minimum Purchase Order Value


  • Default avatar
    blake4    
     13 years ago
    0

    Hello Seyi,

    Please excuse me if this has already been asked, I did a quick search in your Forum and on Google and couldn't find an answer.

    I have a minimum purchase order value for my store of $300.00 and I would like to provide my customers the option to purchase a $25 gift certificate without anything else in their cart.

    Is there a way to exclude gift certificates from the minimum purchase order value?

    Thanks,
    Blake
  • Your avatar
    seyi    
     13 years ago
    0

    I dont think this has been covered yet. in both
    www/administrator/components/com_virtuemart/html/basket.php and
    www/administrator/components/com_virtuemart/html/ro_basket.php

    you will find some code such as this
    <?php
    if( !defined'_MIN_POV_REACHED' )) {
        if (
    round($_SESSION['minimum_pov'], 2) > 0.00) {
            if (
    $total_undiscounted >= $GLOBALS['CURRENCY']->convert$_SESSION['minimum_pov'] )) {
                
    // OKAY!
                
    define ('_MIN_POV_REACHED''1');
            }
        } else {
            
    define ('_MIN_POV_REACHED''1');
        }
    }
    ?>


    Update it to look like this
    <?php
    if( !defined'_MIN_POV_REACHED' )) {
        if (
    round($_SESSION['minimum_pov'], 2) > 0.00) {
            
    # seyi_code
            
    $_giftcert_products = array(17,21);
            
    $is_giftcert false;
            for (
    $i=0;$i<$_SESSION['cart']["idx"];$i++) {
                if(
    in_array($_SESSION['cart'][$i]['product_id'],$_giftcert_products)) {
                    
    $is_giftcert true;
                    break;
                }
            }
            if ( 
    $is_giftcert
            
    || $total_undiscounted >= $GLOBALS['CURRENCY']->convert$_SESSION['minimum_pov'] )) {
                
    // OKAY!
                
    define ('_MIN_POV_REACHED''1');
            }
        } else {
            
    define ('_MIN_POV_REACHED''1');
        }
    }
    ?>


    Where $_giftcert_products is a list of product id's that are gift certificate. Note, this is untested code, so do test it and be comfortable with it before using.



  • Default avatar
    blake4    
     13 years ago
    0

    Thanks for the code, it works perfectly if the shopper just purchases a Gift Certificate.

    But if the shopper combines other items from the store (with the Gift Certificate) that total less than $300.00, they can still checkout.

    Do you see a way to fix this?
  • Your avatar
    seyi    
     13 years ago
    0

    I thought if a gift certificate was added to the cart then the min value thing goes away. You can try this instead

    <?php
    if( !defined'_MIN_POV_REACHED' )) {
        if (
    round($_SESSION['minimum_pov'], 2) > 0.00) {
            
    # seyi_code
            
    $_giftcert_products = array(17,21);
            
    $_products_in_cart = array();
            for (
    $i=0;$i<$_SESSION['cart']["idx"];$i++) { $_products_in_cart[] = $_SESSION['cart'][$i]['product_id']; }
            
    $_invalid_products array_diff($_products_in_cart,$_giftcert_products);
            
    $is_giftcert = !empty($_products_in_cart) && empty($_invalid_products) ? true false;

            if (
    $is_giftcert
            
    || $total_undiscounted >= $GLOBALS['CURRENCY']->convert$_SESSION['minimum_pov'] )) {
                
    // OKAY!
                
    define ('_MIN_POV_REACHED''1');
            }
        } else {
            
    define ('_MIN_POV_REACHED''1');
        }
    }
    ?>


    Again, untested
  • Default avatar
    blake4    
     13 years ago
    0

    Thank you Seyi, this works perfectly.

    I think this might be useful for others who want to sell Gift Certificates that cost less than their store minimum purchase amount.

    I gave you a donation through PayPal to show my appreciation.

    Take care,
    Blake
  • Your avatar
    seyi    
     13 years ago
    0

    Thanks Blake for the donation, it is very much appreciated.

    It is now part of the forum, so others who search will be able to use it too.