Author Topic: Virtuemart 100% discount.  (Read 1947 times)

chetanmadaan

  • 3rd party VirtueMart Developer
  • Jr. Member
  • *
  • Posts: 291
Virtuemart 100% discount.
« on: March 15, 2011, 01:38:32 am »
we are giving our 100% discount to users who bought the software in 2011 January or Feburary and we are giving out downloads.

the problem is that as the price is $0 (after the user uses the coupon code) and no payment method if chosen and by default the order status is pending.

is there a way to change it to confirmed.
thanks

seyi

  • 3rd party VirtueMart Developer
  • Jr. Member
  • *
  • Posts: 401
    • AwoDev
Re: Virtuemart 100% discount.
« Reply #1 on: March 15, 2011, 10:00:08 am »
I know there is a change in 116 and 117 that locks this up.  So this solution should work if you are using one of these versions.

in www/administrator/components/com_virtuemart/classes/ps_checkout.php, in function add, around line 1200 should be this code
Code: [Select]
<?php
if (isset($_PAYMENT)) {
if( $enable_processor == "Y" || stristr($_PAYMENT->payment_code'_API' ) !== false ) {
if( $d['new_order_status'] != 'P' ) {
$d['order_status'] = $d['new_order_status'];
$update_order true;
} elseif( defined($_PAYMENT->payment_code.'_VERIFIED_STATUS')) {
$d['order_status'] = constant($_PAYMENT->payment_code.'_VERIFIED_STATUS');
$update_order true;
}
} elseif( $order_total == 0.00 ) {
// If the Order Total is zero, we can confirm the order to automatically enable the download
$d['order_status'] = ENABLE_DOWNLOAD_STATUS;
$update_order true;
}
}
?>

change it back to version 115 code
Code: [Select]
<?php
if (isset($_PAYMENT)) {
if( $enable_processor == "Y" || stristr($_PAYMENT->payment_code'_API' ) !== false ) {
if( $d['new_order_status'] != 'P' ) {
$d['order_status'] = $d['new_order_status'];
$update_order true;
} elseif( defined($_PAYMENT->payment_code.'_VERIFIED_STATUS')) {
$d['order_status'] = constant($_PAYMENT->payment_code.'_VERIFIED_STATUS');
$update_order true;
}
}
} elseif( 
$order_total == 0.00 ) {
// If the Order Total is zero, we can confirm the order to automatically enable the download
$d['order_status'] = ENABLE_DOWNLOAD_STATUS;
$update_order true;
}
?>

the first version (i think) checks to see if there is a payment before checking if the order total is 0, which does not make sense.  The second version checks if there is a payment or if the order total is 0.
Seyi A
--------------------
Promotion enhancement for Virtuemart:
   - AwoCoupon FREE - http://www.awocoupon.com/starter
   - AwoCoupon Pro - http://awodev.com/products/joomla/awocoupon
   - AwoRewards - http://awodev.com/products/joomla/aworewards
   - AwoAffiliate - http://awodev.com/products/joomla/awoaffiliate

chetanmadaan

  • 3rd party VirtueMart Developer
  • Jr. Member
  • *
  • Posts: 291
Re: Virtuemart 100% discount.
« Reply #2 on: March 15, 2011, 15:40:45 pm »
Seyi - you are the best.

snelson

  • Beginner
  • *
  • Posts: 17
Re: Virtuemart 100% discount.
« Reply #3 on: June 08, 2011, 01:13:49 am »
Thanks Seyi! This fix works in VM 118 also.

I about went blind trying to identify the difference in the two sets of code. It's very subtle and only involves moving one closing brace from the very bottom of the code up about 6 lines.

lindapowers

  • Full Member
  • ***
  • Posts: 1335
  • If you're going through hell, keep going.
    • Venta de naranjas online y mandarinas
  • Skype Name: manu.gonzalez91
  • VirtueMart Version: Latest avi
Re: Virtuemart 100% discount.
« Reply #4 on: December 12, 2011, 10:57:15 am »
Hi Seyi I'm having a strange issue since I installed your awocoupon component:

Order status for payed credit card orders stays pending, this worked before without issues but after installing your coupon system and one of our customers used a copun each all the orders after than one remain as pending and we don't recieve any e-mail from the bank or confirmation for the payment.

This is how our ps_checkout.php looks:

Code: [Select]
$update_order = false;
if (isset($_PAYMENT)) {
    if( $enable_processor == "Y" || stristr($_PAYMENT->payment_code, '_API' ) !== false ) {
if( $d['new_order_status'] != 'P' ) {
$d['order_status'] = $d['new_order_status'];
$update_order = true;
} elseif( defined($_PAYMENT->payment_code.'_VERIFIED_STATUS')) {
$d['order_status'] = constant($_PAYMENT->payment_code.'_VERIFIED_STATUS');
$update_order = true;
}
} elseif( $order_total == 0.00 ) {
// If the Order Total is zero, we can confirm the order to automatically enable the download
$d['order_status'] = ENABLE_DOWNLOAD_STATUS;
$update_order = true;
}
}
if ( $update_order ) {
require_once(CLASSPATH."ps_order.php");
$ps_order = new ps_order();
$ps_order->order_status_update($d);
}

Thanks

seyi

  • 3rd party VirtueMart Developer
  • Jr. Member
  • *
  • Posts: 401
    • AwoDev
Re: Virtuemart 100% discount.
« Reply #5 on: December 12, 2011, 13:05:07 pm »
that is strange.  AwoCoupon does not alter the payment method, so I would guess there is a runtime fatal error that stops execution somewhere (before the order can be confirmed and emailed).  Check your error logs.
Seyi A
--------------------
Promotion enhancement for Virtuemart:
   - AwoCoupon FREE - http://www.awocoupon.com/starter
   - AwoCoupon Pro - http://awodev.com/products/joomla/awocoupon
   - AwoRewards - http://awodev.com/products/joomla/aworewards
   - AwoAffiliate - http://awodev.com/products/joomla/awoaffiliate