If this is your first visit, check our documentation. To post, register or login.
Forums / General Questions / Products that can't be purchased with vouchers

Products that can't be purchased with vouchers

Started by kalastaja on 14 Mar 2015, 9:19 PM · Views: 486

Results 1 to 4 of 4
14 Mar 2015, 9:19 PM
#1
kalastaja avatar

kalastaja

Zen Follower

Join Date:
Mar 2010
Location:
Finland
Posts:
465
Plugin Contributions:
0

Products that can't be purchased with vouchers

Is it possible - in any way - to have a set of products, that can't be purchased with gift vouchers only on the spot with "hard cash"? I.e. the checkout would recognize and abort, if attempted! Please humor me and don't dissect why I need it, just say if you think it's possible!:blush:

14 Mar 2015, 9:24 PM
#2
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Products that can't be purchased with vouchers

kalastaja:

Is it possible - in any way - to have a set of products, that can't be purchased with gift vouchers only on the spot with "hard cash"? I.e. the checkout would recognize and abort, if attempted! Please humor me and don't dissect why I need it, just say if you think it's possible!:blush:

Thought that the gift vouchers could be assigned to apply or not apply to certain product...

Would need to know what conditions are applying the gift voucher to the product(s) and what conditions need to exist to prevent the scenario undesired... How much of an abort are you looking for? Product to be removed from the cart and the rest of the purchase continue on? Return to the shopping cart? Return to elsewhere?

Otherwise, yeah possible... Just about anything is...

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

15 Mar 2015, 4:43 AM
#3
kalastaja avatar

kalastaja

Zen Follower

Join Date:
Mar 2010
Location:
Finland
Posts:
465
Plugin Contributions:
0

Re: Products that can't be purchased with vouchers

The scenery would be as follows - no "abortion" needed. Just disable the gift voucher field, if this product (e.g. id = 15 or 16) is present. The situation is then: either the customer aborts the purchases or he pays with a credit card. There need not be any possibility to pay partially with vouchers - it's all or nothing.

15 Mar 2015, 3:54 PM
#4
kalastaja avatar

kalastaja

Zen Follower

Join Date:
Mar 2010
Location:
Finland
Posts:
465
Plugin Contributions:
0

Re: Products that can't be purchased with vouchers

Found the "credit_selection()"-function (includes/modules/order_total/ot_gv,php), where the following code seems to do the trick:

 function credit_selection() {
    global $db, $currencies;

    //DTC->
    global $order;
    $level_purchase = false;
    for ($i = 0, $n = sizeof($order->products); $i < $n; $i++)  {
      $the_id = $order->products[$i]['id'];
      if ($the_id <= 5) $level_purchase = true;
    }
    if ($level_purchase) return $selection;
    //->DTC
    .......

The credit_selection()-function already returns an unspecified $selection - so I just did the same....:blush:

BTW: What is the use of the "zen_products_lookup()"-function used in other places? The "$order->products[$i]['id']" does the trick, doesn't it?