Skip to content

Commit

Permalink
Fixed Extra Fee for PayPal
Browse files Browse the repository at this point in the history
  • Loading branch information
Yaroslav Voronoy committed Nov 22, 2015
1 parent fe4931d commit 556c28d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
18 changes: 18 additions & 0 deletions app/code/local/Voronoy/ExtraFee/Model/Observer.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class Voronoy_ExtraFee_Model_Observer
* Process Sales Rule Model Before Save
*
* @param $observer
* @return $this
*/
public function beforeSaveSalesRuleModel($observer)
{
Expand All @@ -45,6 +46,7 @@ public function beforeSaveSalesRuleModel($observer)
* Prepare Form for Sales Rule
*
* @param $observer
* @return $this
*/
public function prepareFormSalesRuleEdit($observer)
{
Expand Down Expand Up @@ -76,4 +78,20 @@ public function prepareFormSalesRuleEdit($observer)
Mage_SalesRule_Model_Rule::CART_FIXED_ACTION))
);
}

/**
* PayPal prepare request
*
* @param $observer
*/
public function paypalPrepareLineItems($observer)
{

/* @var $cart Mage_Paypal_Model_Cart */
$cart = $observer->getEvent()->getPaypalCart();
$address = $cart->getSalesEntity()->getIsVirtual() ?
$cart->getSalesEntity()->getBillingAddress() : $cart->getSalesEntity()->getShippingAddress();
$feeAmount = $address->getExtraFeeRuleAmount();
$cart->updateTotal(Mage_Paypal_Model_Cart::TOTAL_TAX, $feeAmount);
}
}
12 changes: 10 additions & 2 deletions app/code/local/Voronoy/ExtraFee/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,20 @@
</salesrule_rule_save_before>
<adminhtml_block_salesrule_actions_prepareform>
<observers>
<voronoy_extrafee>
<voronoy_extrafee_prepare_form>
<class>voronoy_extrafee/observer</class>
<method>prepareFormSalesRuleEdit</method>
</voronoy_extrafee>
</voronoy_extrafee_prepare_form>
</observers>
</adminhtml_block_salesrule_actions_prepareform>
<paypal_prepare_line_items>
<observers>
<voronoy_extrafee_paypal_prepare>
<class>voronoy_extrafee/observer</class>
<method>paypalPrepareLineItems</method>
</voronoy_extrafee_paypal_prepare>
</observers>
</paypal_prepare_line_items>
</events>
</global>
<frontend>
Expand Down

0 comments on commit 556c28d

Please sign in to comment.