diff --git sites/all/modules/commerce_coupon_pct/commerce_coupon_pct.rules.inc sites/all/modules/commerce_coupon_pct/commerce_coupon_pct.rules.inc
index 3731a75dff0ac064d92a2feee1c96b3f6889c0ca..e61c5f1d27dd2d8ba00a7c568eca3d34a9159437 100644
--- sites/all/modules/commerce_coupon_pct/commerce_coupon_pct.rules.inc
+++ sites/all/modules/commerce_coupon_pct/commerce_coupon_pct.rules.inc
@@ -9,79 +9,177 @@
  * Implements hook_rules_action_info().
  */
 function commerce_coupon_pct_rules_action_info() {
-  $actions = array();
-  $actions['commerce_coupon_pct_apply_to_product_line_item'] = array(
-    'label' => t('Apply a percentage coupon to a product line item'),
-    'parameter' => array(
-      'line_item' => array(
-        'type' => 'commerce_line_item',
-        'label' => t('Line item'),
-      ),
-      'coupon' => array(
-        'type' => 'commerce_coupon',
-        'label' => t('Coupon'),
-      ),
-      'component_name' => array(
-        'type' => 'text',
-        'label' => t('Price component type'),
-        'description' => t('Price components track changes to prices made during the price calculation process, and they are carried over from the unit price to the total price of a line item. When an order total is calculated, it combines all the components of every line item on the order. When the unit price is altered by this action, the selected type of price component will be added to its data array and reflected in the order total display when it is formatted with components showing. Defaults to base price, which displays as the order Subtotal.'),
-        'options list' => 'commerce_price_component_titles',
-        'default value' => 'base_price',
-      ),
-      'round_mode' => array(
-        'type' => 'integer',
-        'label' => t('Price rounding mode'),
-        'description' => t('Round the resulting price amount after performing this operation.'),
-        'options list' => 'commerce_round_mode_options_list',
-        'default value' => COMMERCE_ROUND_HALF_UP,
-      ),
-    ),
-    'base' => 'commerce_coupon_pct_apply_to_product_line_item',
-    'group' => t('Commerce Coupon'),
-  );
-
-  return $actions;
+    $actions = array();
+    $actions['commerce_coupon_pct_apply_to_product_line_item'] = array(
+        'label' => t('Apply a percentage coupon to a product line item'),
+        'parameter' => array(
+            'line_item' => array(
+                'type' => 'commerce_line_item',
+                'label' => t('Line item'),
+            ),
+            'coupon' => array(
+                'type' => 'commerce_coupon',
+                'label' => t('Coupon'),
+            ),
+            'component_name' => array(
+                'type' => 'text',
+                'label' => t('Price component type'),
+                'description' => t('Price components track changes to prices made during the price calculation process, and they are carried over from the unit price to the total price of a line item. When an order total is calculated, it combines all the components of every line item on the order. When the unit price is altered by this action, the selected type of price component will be added to its data array and reflected in the order total display when it is formatted with components showing. Defaults to base price, which displays as the order Subtotal.'),
+                'options list' => 'commerce_price_component_titles',
+                'default value' => 'base_price',
+            ),
+            'round_mode' => array(
+                'type' => 'integer',
+                'label' => t('Price rounding mode'),
+                'description' => t('Round the resulting price amount after performing this operation.'),
+                'options list' => 'commerce_round_mode_options_list',
+                'default value' => COMMERCE_ROUND_HALF_UP,
+            ),
+        ),
+        'base' => 'commerce_coupon_pct_apply_to_product_line_item',
+        'group' => t('Commerce Coupon'),
+    );
+
+    $actions['commerce_coupon_pct_apply_to_total'] = array(
+        'label' => t('Apply a percentage coupon to the order total'),
+        'parameter' => array(
+            'coupon' => array(
+                'type' => 'commerce_coupon',
+                'label' => t('Coupon'),
+            ),
+            'commerce_order' => array(
+                'type' => 'commerce_order',
+                'label' => t('commerce order'),
+            ),
+            'component_name' => array(
+                'type' => 'text',
+                'label' => t('Price component type'),
+                'description' => t('Price components track changes to prices made during the price calculation process, and they are carried over from the unit price to the total price of a line item. When an order total is calculated, it combines all the components of every line item on the order. When the unit price is altered by this action, the selected type of price component will be added to its data array and reflected in the order total display when it is formatted with components showing. Defaults to base price, which displays as the order Subtotal.'),
+                'options list' => 'commerce_price_component_titles',
+                'default value' => 'base_price',
+            ),
+            'round_mode' => array(
+                'type' => 'integer',
+                'label' => t('Price rounding mode'),
+                'description' => t('Round the resulting price amount after performing this operation.'),
+                'options list' => 'commerce_round_mode_options_list',
+                'default value' => COMMERCE_ROUND_HALF_UP,
+            ),
+        ),
+        'provides' => array(
+            'commerce_coupon_pct_line_item' => array(
+                'type' => 'commerce_coupon_pct_line_item',
+                'label' => t('commerce coupon percent line item'),
+            ),
+        ),
+        'base' => 'commerce_coupon_pct_apply_to_total',
+        'group' => t('Commerce Coupon'),
+        'callbacks' => array(
+            'execute' => 'commerce_coupon_pct_apply_to_total',
+        ),
+    );
+    return $actions;
 }
 
-function commerce_coupon_pct_apply_to_product_line_item($line_item, $coupon, $component_name, $round_mode) {
-  $coupon_wrapper = entity_metadata_wrapper('commerce_coupon', $coupon);
-  $fields = $coupon_wrapper->getPropertyInfo();
-  // Apply the coupon just if it's active, the type is of pct and it has the
-  // field for percentage set.
-  if ($coupon->is_active == TRUE && $coupon->type == 'commerce_coupon_pct'
-      && isset($fields['commerce_coupon_percent_amount']) && $coupon_wrapper->commerce_coupon_percent_amount->value() > 0) {
-    $rate = $coupon_wrapper->commerce_coupon_percent_amount->value();
-    if ($rate > 1) {
-      // Ensure that the rate is never bigger then 100%
-      $rate = $rate / 100;
-    }
-    else {
-      return;
+function commerce_coupon_pct_apply_to_total($coupon, $commerce_order, $component_name, $round_mode) {
+    $coupon_wrapper = entity_metadata_wrapper('commerce_coupon', $coupon);
+    $fields = $coupon_wrapper->getPropertyInfo();
+    // Apply the coupon just if it's active, the type is of pct and it has the
+    // field for percentage set.
+    if ($coupon->is_active == TRUE && $coupon->type == 'commerce_coupon_pct'
+            && isset($fields['commerce_coupon_percent_amount']) && $coupon_wrapper->commerce_coupon_percent_amount->value() > 0) {
+        $rate = $coupon_wrapper->commerce_coupon_percent_amount->value();
+        if ($rate > 1) {
+            // Ensure that the rate is never bigger then 100%
+            $rate = $rate / 100;
+        } else {
+            return;
+        }
+
+//Step One is to get subtotal
+
+        $line_item_types = commerce_product_line_item_types();
+        $order_wrapper = entity_metadata_wrapper('commerce_order', $commerce_order);
+        $balance = commerce_line_items_total($order_wrapper->commerce_line_items, $line_item_types);
+
+//Step Two multiply the percent coupon rate against the subtotal
+
+        $amount = commerce_round($round_mode, $balance['amount'] * $rate);
+
+
+//Step Three is to get the difference, and currency code if needed later
+        $current_amount = $balance['amount'];
+        $updated_amount = commerce_round($round_mode, $current_amount - $amount);
+
+        $difference = array(
+            'amount' => (-abs($updated_amount - $current_amount) ),
+            'currency_code' => $balance['currency_code'],
+                //'data' => array(),
+        );
+
+        if (!($commerce_order instanceof EntityMetadataWrapper)) {
+            $commerce_order = entity_metadata_wrapper('commerce_order', $commerce_order);
+        }
+        $line_item = commerce_coupon_line_item_new($coupon, $commerce_order->order_id->raw());
+        $line_item_wrapper = entity_metadata_wrapper('commerce_line_item', $line_item);
+
+        // Set the unit price on the line item object.
+        $line_item_wrapper->commerce_unit_price->amount = $difference['amount'];
+        $line_item_wrapper->commerce_unit_price->currency_code = $difference['currency_code'];
+
+        // Add the base price to the components array.
+        if ($coupon->is_active && !commerce_price_component_load($line_item_wrapper->commerce_unit_price->value(), $component_name)) {
+            $line_item_wrapper->commerce_unit_price->data = commerce_price_component_add(
+                    $line_item_wrapper->commerce_unit_price->value(), $component_name, $line_item_wrapper->commerce_unit_price->value(), TRUE, FALSE
+            );
+        }
+//Voila! Save the commerce line item :)
+        commerce_line_item_save($line_item);
+
+        $commerce_order->commerce_line_items[] = $line_item;
+
+        return array('commerce_coupon_line_item' => $line_item);
     }
+}
 
-    // Get the price component to use in this price.
-    $price_component_name = $coupon_wrapper->price_component_name->value();
+function commerce_coupon_pct_apply_to_product_line_item($line_item, $coupon, $component_name, $round_mode) {
+    $coupon_wrapper = entity_metadata_wrapper('commerce_coupon', $coupon);
+    $fields = $coupon_wrapper->getPropertyInfo();
+    // Apply the coupon just if it's active, the type is of pct and it has the
+    // field for percentage set.
+    if ($coupon->is_active == TRUE && $coupon->type == 'commerce_coupon_pct'
+            && isset($fields['commerce_coupon_percent_amount']) && $coupon_wrapper->commerce_coupon_percent_amount->value() > 0) {
+        $rate = $coupon_wrapper->commerce_coupon_percent_amount->value();
+        if ($rate > 1) {
+            // Ensure that the rate is never bigger then 100%
+            $rate = $rate / 100;
+        } else {
+            return;
+        }
 
-    $wrapper = entity_metadata_wrapper('commerce_line_item', $line_item);
-    $unit_price = commerce_price_wrapper_value($wrapper, 'commerce_unit_price', TRUE);
-    $amount = commerce_round($round_mode, $unit_price['amount'] * $rate);
+        // Get the price component to use in this price.
+        $price_component_name = $coupon_wrapper->price_component_name->value();
 
-    // Calculate the updated amount and create a price array representing the
-    // difference between it and the current amount.
-    $current_amount = $unit_price['amount'];
-    $updated_amount = commerce_round($round_mode, $current_amount - $amount);
+        $wrapper = entity_metadata_wrapper('commerce_line_item', $line_item);
+        $unit_price = commerce_price_wrapper_value($wrapper, 'commerce_unit_price', TRUE);
+        $amount = commerce_round($round_mode, $unit_price['amount'] * $rate);
 
-    $difference = array(
-      'amount' => $updated_amount - $current_amount,
-      'currency_code' => $unit_price['currency_code'],
-      'data' => array(),
-    );
+        // Calculate the updated amount and create a price array representing the
+        // difference between it and the current amount.
+        $current_amount = $unit_price['amount'];
+        $updated_amount = commerce_round($round_mode, $current_amount - $amount);
 
-    // Set the amount of the unit price and add the difference as a component.
-    $wrapper->commerce_unit_price->amount = $updated_amount;
+        $difference = array(
+            'amount' => $updated_amount - $current_amount,
+            'currency_code' => $unit_price['currency_code'],
+            'data' => array(),
+        );
 
-    $wrapper->commerce_unit_price->data = commerce_price_component_add(
-        $wrapper->commerce_unit_price->value(), $price_component_name, $difference, TRUE
-    );
-  }
+        // Set the amount of the unit price and add the difference as a component.
+        $wrapper->commerce_unit_price->amount = $updated_amount;
+
+        $wrapper->commerce_unit_price->data = commerce_price_component_add(
+                $wrapper->commerce_unit_price->value(), $price_component_name, $difference, TRUE
+        );
+    }
 }
