Hi,

I set up a site-wide flexicharge called "Flat postage fee" for my apparel products, but it's not showing up in the order summary. I have no other shipping options configured.

Any idea what could be wrong? I am using Drupal 5.1 with the latest CVS version of Ecommerce.

Thanks in advance!

CommentFileSizeAuthor
#14 flexicharge_1.patch2.21 KBRok Žlender

Comments

slombardi’s picture

Version: 5.x-4.x-dev » 5.x-3.0
Assigned: Unassigned » slombardi
Category: bug » support

Hi
I'm having the same problem as well.
Couldn't find any suggestion in topics on flexicharge.
Does anyone have any Idea on this?

thanks..

Bob445’s picture

Hello,
I'm having the same problem.
Someone have solution to fix it ?

Thanks

slayerment’s picture

Do you have a region enabled for it or have the checkbox checked for this region? I know I was having this same problem because I forgot to check that...

Bob445’s picture

For me it's fixed, I don't know why ...

hanskuiters’s picture

I have the regions module enabled but do not use it.
Setting a flexicharge works fine, it shows in checkout and does what it has to do.
After changing the flexicharge-setting it is not showing anymore in checkout.
When creating a new setting, it shows again in checkout.

mutzel’s picture

"I have the regions module enabled but do not use it.
Setting a flexicharge works fine, it shows in checkout and does what it has to do.
After changing the flexicharge-setting it is not showing anymore in checkout.
When creating a new setting, it shows again in checkout."

same problem for me too! any solutions yet?

a new simple shipping creates a visible charge of 0 at the checkout but after editing it is not visible anymore

mutzel’s picture

For me it's fixed, I do know why ... :D

You need to select the "Product types".

So i assume that the description of "Product types" is incorrect:

"Please choose the products that this charge applies to. No selection indicates all products. Charge will apply only once, if any product in the cart matches this list."

brmassa’s picture

Status: Active » Needs review

Guys,

Martin was right: the product types field is REQUIRED. you have to choose all product types if you need to. (its only needed if you edited you flexicharge, because the buggy code ignores it when you create one and dont edit it)

or the description should be changed or a new patch should be done:

      // Remove charges that does not apply by PRODUCT.
      foreach($charges AS $charge) {
        $apply = FALSE;
        // If there is a product filter on the charge.
        if (count($charge->ptypes)) {
          // Check if any ptypes match the filter.
          foreach ($txn->items AS $item) {
            if (!is_array($charge->ptypes) || in_array($item->ptype, $charge->ptypes)) {
              $apply = TRUE;
              break;
            }
          }
        }
+        else {
+          $apply = TRUE;
+        }
        if ($apply == FALSE) {
          // No items match then charge so unset
          unset($charges[$charge->chid]);
        }

best regards,

massa

slombardi’s picture

Hi..
I changed those settings selecting the product types I needed (and also the user roles) but shipping still disp could it be?
says a 0 in the final invoice...
Help!
Does anyone have an idea on what it could be?
thanks

slombardi’s picture

Hi..
I changed those settings selecting the product types I needed (and also the user roles) but shipping still disp could it be?
says a 0 in the final invoice...
Help!
Does anyone have an idea on what it could be?
thanks

vegera’s picture

Hello!
I found 2 errors in the flexicharge module.
#1 missing 'hide_if_zero' field in the insert into sql command. The result: ptype field is in bad place at the ec_flexicharge table.
#2 role error in the checkoutapi function:
$charge->roles return with rids (roles ids), but the $user->roles return with the role-names. Ofcourse array_intersect($user->roles, $charge->roles)) function return with no score.
Possible (not to good) solution for me:

$all_roles= user_roles();
foreach($charge->roles AS $charge_rid)
{$charge_roles[$charge_rid]=$all_roles[$charge_rid];}
// Check if any roles match the filter.
if (is_array($charge->roles) && !count(array_intersect($user->roles, $charge_roles))) {
unset($charges[$charge->chid]);
}
}

Sorry for my horrible english.
Joe Vegera

jeremdow’s picture

vegera -

Thanks - your user role fix worked for us also.

We also had to make some changes to the update and insert statements in the flexicharge_admin_form_submit function to include hide_if_zero and reorder the sequence to prevent the user roles from being miscarried.

Code below - again worked for us, but no guarantees :)

function flexicharge_admin_form_submit($form_id, $form) {
// Get the form elements required by the charge provider
$f = $provider .'_flexicharge_form_validate';
if (function_exists($f)) {
$form = $f($form_id, $form);
}

$settings = array();
if (isset($form['elements'])) {
foreach($form['elements'] AS $fieldset) {
$settings = array_merge($fieldset, $settings);
}
$settings = serialize($settings);
}
else {
$settings = '';
}

$ptypes = serialize($form['module']['ptypes']);
$roles = serialize($form['module']['roles']);

if ($form['module']['chid']) {
db_query("UPDATE {ec_flexicharge} SET display = '%s', operator = %d, rate = %f, position = %d, subtotal_before = %d, subtotal_after = %d, already_added = %d, hide_if_zero = %d, ptypes = '%s', roles = '%s', settings = '%s' WHERE chid = %d",
$form['module']['display'], $form['module']['operator'],
$form['module']['rate'], $form['module']['position'],
$form['module']['subtotal_before'], $form['module']['subtotal_after'],
$form['module']['already_added'], $form['module']['hide_if_zero'],
$ptypes, $roles, $settings, $form['module']['chid']);
}
else {
db_query("INSERT INTO {ec_flexicharge}
( provider, method, display,
operator, rate, position,
subtotal_before, subtotal_after,
already_added, hide_if_zero, ptypes, roles, settings)
VALUES ('%s', '%s', '%s', %d, %f, %d, %d, %d, %d, %d, '%s', '%s', '%s')",
$form['module']['provider'], $form['module']['method'],
$form['module']['display'], $form['module']['operator'],
$form['module']['rate'], $form['module']['position'],
$form['module']['subtotal_before'], $form['module']['subtotal_after'],
$form['module']['already_added'], $form['module']['hide_if_zero'],
$ptypes, $roles, $settings);
}

drupal_set_message(t('The charge has been saved.'));
drupal_goto('admin/ecsettings/flexicharge');
}

Only the SQL statements were modified from the original code, but I included the whole function for context.

Cheers,

JMD

jeremdow’s picture

To follow up - I also had to add this after the call to _flexicharge_partners in order for hide if zero to work.

      // Call this to include() the method files.
      _flexicharge_partners();
      
      //hide_if_zero fix - jmd
      $t = store_transaction_load($txn);
      
      foreach($charges AS $charge) {
      
        $f = 'general_' . $charge->provider . '_flexicharge_calculate';     
        
        if (function_exists($f)){
          $calculate = $f($txn, $charge, store_transaction_calc_gross($t));
          
          if (!$calculate && $charge->hide_if_zero) {
            unset($charges[$charge->chid]);
          }
        }
      }

JMD

Rok Žlender’s picture

StatusFileSize
new2.21 KB

I created a patch that includes #12 and #11. It works for me.
#13 didn't work for me bacause function general_*_flexicharge_calculate does not exist. Jeremdow if you can maybe create a patch or explain your code a bit.

slombardi’s picture

Hi,
could you please post the patched files as I'm not able to run patches as I have no access to shell
Thanks in advance
S

brmassa’s picture

Assigned: slombardi » brmassa
Status: Needs review » Patch (to be ported)

Guys,

fixed on EC4.
the solution, however, was not the providided. to port to EC3, take a look on http://cvs.drupal.org/viewcvs/drupal/contributions/modules/ecommerce/con...

regards,

massa

brmassa’s picture

Category: support » bug

its a bug

gordon’s picture

Status: Patch (to be ported) » Fixed

I have backported this to 4.7.x-3.0-dev and 5.x-3.x-dev

Anonymous’s picture

Status: Fixed » Closed (fixed)