-1

I have a complex shipping price grid, with :

  • Different modes : tracked or not
  • Different zones : France, EU, World
  • Different prices per weight steps (<250g, <400g, etc.)

I started to implement that using Commerce shipping, Commerce flat rate and Commerce physical products, and a lot of rules, but now I need to apply a fixed VAT rate (20%) on shipping ONLY for tracked shipping in France.

Any idea of how I can do that? The VAT rate rule calculation seems to apply everytime, I don't know how to say "only for tracked shipping service".

Maybe it's time to make my own shipping module?

  • Ok, it seems it can be done with a condition on the VAT rate rule, if I use a PHP code condition, I can test the shipping line item. – grubshka Dec 10 '15 at 20:58
0

As the author answered in a comment, this can be achieved by adding a rule condition to the rule that applies the VAT rate. Often pricing tables requires custom PHP code. Though, it's better to create a custom module and define your own rule condition in code.

You just have to implement one of the following hooks:

Custom Rules Action (not what you need, but good to know)

/**
 * Implements hook_rules_action_info()
 */
function MODULE_rules_action_info() {
  return array(
    'machine_name' => array(
      'label' => 'Custom Action',
    ),
  );
}

/**
 * machine_name custom action
 */
function machine_name() {
  // do action
}

Custom Rules Condition (definitely what you need)

/**
 * Implements hook_rules_condition_info()
 */
function MODULE_rules_condition_info() {
  return array(
    'machine_name_condition' => array(
      'label' => 'Custom Condition',
      'arguments' => array(
        'type' => 'user', // there are lots of types
        'label' => 'Fancy user',
      ),
    ),
  );
}

/**
 * machine_name_condition custom rules condition
 */
function machine_name_condition($user) {
  if ($user->uid == 1) return true;
  return false;
}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.