Advance software forum
May 18, 2012, 08:14:36 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: Oscomerce AJAX Checkout + Coupon Discount  (Read 1451 times)
0 Members and 2 Guests are viewing this topic.
jbuc
Newbie
*
Offline Offline

Posts: 3


View Profile
« on: March 04, 2009, 04:23:41 PM »

How come the coupon discounts (Discount Coupon Codes) are not showing up under the subtotal amount? Is there an easy way to make the discount appear.

Thank you.
Logged
Alex
Administrator
Full Member
*****
Offline Offline

Posts: 128


View Profile
« Reply #1 on: March 05, 2009, 01:35:47 AM »

Hey jbuc,

If the discount module is using an order_total module technique, it should work fine. However, you might also check where the coupon
is entered, and add the box (if its the box). If you want a popular redeem coupon contribution to work, its not so easy and requires a lot of
modifications to be done.

I'll see if I can manage that, but your comments will be nice on the version and name of the coupons contrib you are using.
Logged
jbuc
Newbie
*
Offline Offline

Posts: 3


View Profile
« Reply #2 on: March 05, 2009, 08:58:08 AM »

Thanks for the response Alex.
The coupon mod I'm using is Discount Coupon Codes 3.32 /dynamoeffects (http://www.oscommerce.com/community/contributions,4269). I've already made the following changes to ajaxManagerTest.class.php:

ADDED:
      //kgt - discount coupons
  if( tep_session_is_registered( 'coupon' ) && is_object( $order->coupon ) ) {
     $sql_data_array = array( 'coupons_id' => $order->coupon->coupon['coupons_id'],
                             'orders_id' => $insert_id );
     tep_db_perform( TABLE_DISCOUNT_COUPONS_TO_ORDERS, $sql_data_array );
  }
  //end kgt - discount coupons

AFTER:


        $customer_notification = (SEND_EMAILS == 'true') ? '1' : '0';
        $sql_data_array = array('orders_id' => $insert_id,
                                'orders_status_id' => $order->info['order_status'],
                                'date_added' => 'now()',
                                'customer_notified' => $customer_notification,
                                'comments' => $order->info['comments']);
        tep_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array);
      

AND ADDED:
        //kgt - discount coupons
  if( tep_not_null( $coupon ) && is_object( $order->coupon ) ) { //if they have entered something in the coupon field
    $order->coupon->verify_code();
    if( MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DEBUG != 'true' ) {
        if( !$order->coupon->is_errors() ) { //if we have passed all tests (no error message), make sure we still meet free shipping requirements, if any
           if( $order->coupon->is_recalc_shipping() ) tep_redirect( tep_href_link( FILENAME_CHECKOUT_SHIPPING, 'error_message=' . urlencode( ENTRY_DISCOUNT_COUPON_SHIPPING_CALC_ERROR ), 'SSL' ) ); //redirect to the shipping page to reselect the shipping method
        } else {
           if( tep_session_is_registered('coupon') ) tep_session_unregister('coupon'); //remove the coupon from the session
           tep_redirect( tep_href_link( FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode( implode( ' ', $order->coupon->get_messages() ) ), 'SSL' ) ); //redirect to the payment page
        }
    }
   } else { //if the coupon field is empty, unregister the coupon from the session
      if( tep_session_is_registered('coupon') ) { //we had a coupon entered before, so we need to unregister it
      tep_session_unregister('coupon');
      //now check to see if we need to recalculate shipping:
      require_once( DIR_WS_CLASSES.'discount_coupon.php' );
      if( discount_coupon::is_recalc_shipping() ) tep_redirect( tep_href_link( FILENAME_CHECKOUT_SHIPPING, 'error_message=' . urlencode( ENTRY_DISCOUNT_COUPON_SHIPPING_CALC_ERROR ), 'SSL' ) ); //redirect to the shipping page to reselect the shipping method
    }
   }
   //end kgt - discount coupons


AFTER:
 if (is_array($payment_modules->modules)) {



AND ADDED:
   
     //kgt - discount coupons
  if (!tep_session_is_registered('coupon')) tep_session_register('coupon');
  //this needs to be set before the order object is created, but we must process it after
  $coupon = tep_db_prepare_input($HTTP_POST_VARS['coupon']);
  //end kgt - discount coupons


AFTER:
function _showPayment($get) {


AND ADDED:
/* kgt - discount coupons */
   if( MODULE_ORDER_TOTAL_DISCOUNT_COUPON_STATUS == 'true' ) {
?>
      <tr>
        <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
          <tr>
            <td class="main"><?php echo TABLE_HEADING_COUPON; ?></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
          <tr class="infoBoxContents">
            <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
              <tr>
                <td class="main"><?php echo ENTRY_DISCOUNT_COUPON.' '.tep_draw_input_field('coupon', '', 'size="7"'); ?></td>
              </tr>
            </table></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
      </tr>
<?php
   }
/* end kgt - discount coupons */
?>


below the PAYMENT ADDRESS



*I'm using the latest version of oscommerce. Any help would be greatly appreciated!
Logged
jbuc
Newbie
*
Offline Offline

Posts: 3


View Profile
« Reply #3 on: March 06, 2009, 05:56:36 PM »

Any idea Alex?
Logged
Alex
Administrator
Full Member
*****
Offline Offline

Posts: 128


View Profile
« Reply #4 on: March 12, 2009, 07:42:01 AM »

Hello jbuc,

Well, this contrib seems to be integrating inside the payment page, and thus is complicated. If this was a box, everything will be easier.
Seems you have made right changes, but... you will need a lot more. Look how the variables are processed in the payment processing
function, and use the same technique to process your discount codes.

P.S. Or, if you dont have time, try to find a contribution where discount code is entered *NOT* on the payment page, but in the *box* in a left/right column and which is processed through a common ot_coupon coupon order total module. I remeber I saw one on addons at osc site,
and integration of this one was very easy.
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 3.1.1 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!