Hello - I've posted a request for help previously, but not in this support section.

I'm having a problem with duplicate flexicharges on checkout.

I have a discount for a user role, shipping charges (both flexicharge) and a coupon. When I get to the final review page for the order the user discount and the shipping charges already show correctly in the total. There I can enter the coupon code and click 'add'. After doing this there are now duplicate entries for the shipping and the user role discount. The coupon also shows correctly.

If I then remove the coupon from the order, the duplicate charges remain in the total invoice.

I found an earlier post: http://drupal.org/node/118686 that used a patch for version 4.7. I tried this patch but it didn't help, I guess, since I'm using 5.

I've read through the other support requests and haven't seen mention of this, maybe I missed it. Any help would be appreciated.

Thanks!

Comments

Anonymous’s picture

I used the patch at the link you pointed to successfully, running ecomm 3.1 & Drup 5.2

I inserted this code in line 167, note that the callback needs to reflect the .inc filename (in my case upscharge).

   if(is_array($txn->misc)) {
        $i = 0;
        foreach ($txn->misc as $misc) {
          if ($misc->callback == 'general_upscharge_flexicharge_calculate') {
            unset($txn->misc[$i]);
          }
          $i++;
        }
      }

This is very quick & dirty. Any other solutions out there - or chance this might get into core?

brmassa’s picture

Greg,

is there a possibility to you port this patch agains eC4 CVS? i will be glad to commit

regards,

massa

brmassa’s picture

Greg,

is there a possibility to you port this patch agains eC4 CVS? i will be glad to commit

regards,

massa

research37’s picture

gbear,

If I'm trying to fix this in my instance would the include be "coupon"? So I would need to change that one line to:

if ($misc->callback == 'general_coupon_flexicharge_calculate') {

?

If not, how do I figure which include to use? Sorry, I'm pretty new to coding in drupal.

Thanks,

Patrick

dylanb’s picture

Same problem here. I was adding coupons to an order and flexicharge kept adding a shipping charge for each one. Even if I removed the coupon from the order the shipping charge stayed.

Anyway, using the snippet from gbear (comment #1) I fixed the problem. The version of flexicharge I'm using is:

// $Id: flexicharge.module,v 1.8.2.1.2.1.2.17 2007/07/12 02:46:04 gordon Exp $

and the code I ended up using was inserted into the flexicharge_checkoutapi() function just before the switch statement (line 127)...


/**
 * Use checkoutapi to calculate charges, each method has it's own checkout
 * function
 */
function flexicharge_checkoutapi(&$txn, $op, $arg3 = null, $arg4 = null) {
  if ($txn == 'flexicharge') {
    return true;
  }

  // cart_get_items() doesn't do a full node load, so we don't have
  // access to shipping data and therefore need to manually add
  // flexicharge data here.
  // NOTE: this is done like shipping.module
  if (isset($txn->items)) {
    foreach (array_keys($txn->items) as $nid) {
      flexicharge_nodeapi($txn->items[$nid], 'load', NULL);
    }
  }
  
  /////////////////////////
  //my own code
  /////////////////////////
  if(is_array($txn->misc)) {
    $first_shipping = TRUE; //I need to keep at least one shipping charge
    $i = 0;
    foreach ($txn->misc as $misc) {
      //if ($misc->callback == 'simple_shipping_flexicharge_calculate') { //this line didn't work
      if ($misc->description == 'Shipping') { //this line did
        if ($first_shipping){
          $first_shipping = FALSE;
        }else{
          unset($txn->misc[$i]);
        }
      }
      $i++;
    }
  }
  /////////////////////////
  //end of my own code
  /////////////////////////
      
      
  switch ($op) {
    case 'review':

      // Get saved charges from database.
      $charges = _flexicharge_load_charges();
      ...etc...

brmassa’s picture

Status: Active » Closed (fixed)