Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy Pieters committed Jun 14, 2016
2 parents 1cc2975 + 28a8c0e commit c5cb60f
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 89 deletions.
95 changes: 42 additions & 53 deletions app/code/community/Pay/Payment/Block/Adminhtml/Paymentmethods.php
Original file line number Diff line number Diff line change
@@ -1,58 +1,47 @@
<?php

class Pay_Payment_Block_Adminhtml_Paymentmethods extends Mage_Adminhtml_Block_System_Config_Form_Field {

protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) {
$form = $element->getForm();
$parent = $form->getParent();
$scope = $parent->getScope();
$scopeId = $parent->getScopeId();

if($scope == 'stores'){
$store = Mage::app()->getStore($scopeId);
} elseif($scope == 'websites') {
$store = Mage::app()->getWebsite($scopeId);
} else {
$store = Mage::app()->getStore(0);
}


// if (strlen($code = Mage::getSingleton('adminhtml/config_data')->getStore())) { // store level
// $store_id = Mage::getModel('core/store')->load($code)->getId();
// $store = Mage::app()->getStore($store_id);
// } elseif (strlen($code = Mage::getSingleton('adminhtml/config_data')->getWebsite())) { // website level
// $website_id = Mage::getModel('core/website')->load($code)->getId();
// $store = Mage::app()->getWebsite($website_id);
// //$store_id = Mage::app()->getWebsite($website_id)->getDefaultStore()->getId();
//
// } else { // default level
// $store_id = 0;
// $store = Mage::getModel('core/store')->load($code)->getId();
// }
// //$store = Mage::app()->getStore($store_id);
//

try {
$helper = Mage::helper('pay_payment');

$helper->loadOptions($store);

$arrOptions = $helper->getOptions($store);


$output = '';
$arrOptionNames = array();
foreach ($arrOptions as $option) {
$output .= '<img src="' . $option->getImage() . '" /> ' . $option->getName() . '<br />';
// foreach ($option->getSubs() as $sub) {
// $output .= '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src="' . $sub->getImage() . '" /><br />';
// }
}
} catch (Exception $e) {
$output = $e->getMessage();
}

return '<div>' . $output . '</div>';
class Pay_Payment_Block_Adminhtml_Paymentmethods extends Mage_Adminhtml_Block_System_Config_Form_Field
{

protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
{
$form = $element->getForm();
$parent = $form->getParent();
$scope = $parent->getScope();
$scopeId = $parent->getScopeId();

if ($scope == 'stores')
{
$store = Mage::app()->getStore($scopeId);
} elseif ($scope == 'websites')
{
$store = Mage::app()->getWebsite($scopeId);
} else
{
$store = Mage::app()->getStore(0);
}


try
{
$helper = Mage::helper('pay_payment');

$helper->loadOptions($store);

$arrOptions = $helper->getOptions($store);


$output = '';
foreach ($arrOptions as $option)
{
$output .= '<img src="' . $option->getImage() . '" /> ' . $option->getName() . '<br />';
}
} catch (Exception $e)
{
$output = $e->getMessage();
}

return '<div>' . $output . '</div>';
}

}
66 changes: 35 additions & 31 deletions app/code/community/Pay/Payment/Block/Sales/Order/Totals.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,44 @@
*/
class Pay_Payment_Block_Sales_Order_Totals extends Mage_Sales_Block_Order_Totals
{
/**
* Initialize order totals array
*
* @return Mage_Sales_Block_Order_Totals
*/
protected function _initTotals()
{
parent::_initTotals();

$source = $this->getSource();

/**
* Initialize order totals array
*
* @return Mage_Sales_Block_Order_Totals
* Add store rewards
*/
protected function _initTotals()
$totals = $this->_totals;
$newTotals = array();
if (count($totals) > 0)
{
parent::_initTotals();

$source = $this->getSource();

/**
* Add store rewards
*/
$totals = $this->_totals;
$newTotals = array();
if (count($totals)>0) {
foreach ($totals as $index=>$arr) {
if ($index == "grand_total") {
if (((float)$this->getSource()->getPaymentCharge()) != 0) {
$label = Mage::getStoreConfig('pay_payment/general/text_payment_charge', Mage::app()->getStore());
$newTotals['payment_charge'] = new Varien_Object(array(
'code' => 'payment_charge',
'field' => 'payment_charge',
'value' => $source->getPaymentCharge(),
'label' => $label
));
}
}
$newTotals[$index] = $arr;
}
$this->_totals = $newTotals;
foreach ($totals as $index => $arr)
{
if ($index == "grand_total")
{
if (((float)$this->getSource()->getPaymentCharge()) != 0)
{
$label = Mage::getStoreConfig('pay_payment/general/text_payment_charge', Mage::app()->getStore());
$newTotals['payment_charge'] = new Varien_Object(array(
'code' => 'payment_charge',
'field' => 'payment_charge',
'value' => $source->getPaymentCharge(),
'label' => $label
));
}
}

return $this;
$newTotals[$index] = $arr;
}
$this->_totals = $newTotals;
}

return $this;
}
}
3 changes: 3 additions & 0 deletions app/code/community/Pay/Payment/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,9 @@ public static function getTaxCodeFromRate($taxRate)

public static function calculateTaxClass($amountInclTax, $taxAmount)
{
if(!$amountInclTax || !$taxAmount ){
return self::getTaxCodeFromRate(0);
}
$amountExclTax = $amountInclTax - $taxAmount;
if($amountExclTax == 0){ // prevent division by zero
$taxRate = 0;
Expand Down
8 changes: 3 additions & 5 deletions app/code/community/Pay/Payment/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,8 @@
<rewrite>
<sales_totals>Pay_Payment_Block_Adminhtml_Sales_Totals</sales_totals>
<sales_order_totals>Pay_Payment_Block_Adminhtml_Sales_Order_Totals</sales_order_totals>
<sales_order_invoice_totals>Pay_Payment_Block_Adminhtml_Sales_Order_Invoice_Totals
</sales_order_invoice_totals>
<sales_order_creditmemo_totals>Pay_Payment_Block_Adminhtml_Sales_Order_Creditmemo_Totals
</sales_order_creditmemo_totals>
<sales_order_invoice_totals>Pay_Payment_Block_Adminhtml_Sales_Order_Invoice_Totals</sales_order_invoice_totals>
<sales_order_creditmemo_totals>Pay_Payment_Block_Adminhtml_Sales_Order_Creditmemo_Totals</sales_order_creditmemo_totals>
</rewrite>
</adminhtml>
</blocks>
Expand Down Expand Up @@ -116,7 +114,7 @@
<payment_charge translate="title">
<title>Pay.nl betaalmethode kosten</title>
<source_field>payment_charge</source_field>
<amount_prefix></amount_prefix>
<amount_prefix> </amount_prefix>
<font_size>7</font_size>
<display_zero>0</display_zero>
<sort_order>200</sort_order>
Expand Down

0 comments on commit c5cb60f

Please sign in to comment.