Skip to content

Commit

Permalink
Merge pull request #8 from MaWoScha/master
Browse files Browse the repository at this point in the history
Version 1.6.0 - Complete module rework for Magento 1.9
  • Loading branch information
ceefour authored Aug 12, 2019
2 parents 9c27fcf + 1f4d7e8 commit 7aa7e2d
Show file tree
Hide file tree
Showing 19 changed files with 137 additions and 315 deletions.
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Bippo fork on GitHub: https://github.com/bippo/customshippingrate-magento

Please note! Magento version 1.3.2 or higher is *required* to use this extension. Please make sure your Magento install is version 1.3.2 or higher before installing. Also note that this is NOT a per product shipping module.

Also note that if you wish to install the latest 1.5.0 version of this extension, you must set your Prefered State to Beta under the settings tab of your Magento Connect Manager. If you do not it will install the older 1.4.7 version.
Also note that if you wish to install the latest 1.5.0 version of this extension, you must set your Prefered State to Beta under the settings tab of your Magento Connect Manager. If you do not it will install the older 1.4.7 version.

Adds ability to specify a custom shipping rate and title when creating a new order in backend. This allows you to utilize any shipping method and price you want, even if it's not available to customers on the front end.

Expand All @@ -14,14 +14,16 @@ The extension is based on code found in this thread: http://www.magentocommerce.
Thanks go out to szotyi for getting this started and to everyone else that helped test this.

## Version history
* 1.5.0 - Original Version from [Admin Custom Shipping Rate](http://www.magentocommerce.com/magento-connect/i960/extension/1477/admin-custom-shipping-rate) on 30 January 2012
* 1.5.1 - German localization added by [BenRoe](https://github.com/BenRoe) on 2 May 2013
* 1.5.2 - Spanish localization added by [MaWoScha](https://github.com/MaWoScha) on 11 November 2014
* 1.6.1 - update quote model to allow zero price custom rate, added by [adpeate](https://github.com/adpeate/customshippingrate-magento/commit/e9503353b2187b838b9d021a4c9d9b7e7fb291cf) on 2 August 2019
* 1.6.0 - Complete module rework for Magento 1.9 by [ThomasNegeli](https://github.com/ThomasNegeli/customshippingrate-magento/commit/7aa8bd62fb82e587ee050bdeb31274431561c348) on 5 September 2017
* 1.5.3 - Portuguese localization added by [MaWoScha](https://github.com/MaWoScha) on 24 September 2015
* 1.5.2 - Spanish localization added by [MaWoScha](https://github.com/MaWoScha) on 11 November 2014
* 1.5.1 - German localization added by [BenRoe](https://github.com/ThomasNegeli/customshippingrate-magento/commit/dc52053beac7976b35b833f1c1261192db93d33d) on 2 May 2013
* 1.5.0 - Original Version from [Admin Custom Shipping Rate](http://www.magentocommerce.com/magento-connect/i960/extension/1477/admin-custom-shipping-rate) on 30 January 2012

## Known Issues

There is a known issue with this extension if you are charging tax on shipping. As of this writing I have not found a confirmed solution that works for everyone. Please see this thread for more info:
There is a known issue with this extension if you are charging tax on shipping. As of this writing I have not found a confirmed solution that works for everyone. Please see this thread for more info:

http://www.magentocommerce.com/boards/viewthread/214206/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ class Indust_CustomShippingRate_Model_Carrier_Customshippingrate
implements Mage_Shipping_Model_Carrier_Interface
{

CONST BASE_SHIPPING_AMOUNT = 'BASE_SHIPPING_AMOUNT_REGISTRY_KEY';
CONST SHIPPING_AMOUNT = 'SHIPPING_AMOUNT_REGISTRY_KEY';
CONST SHIPPING_DESCRIPTION = 'SHIPPING_DESCRIPTION_REGISTRY_KEY';

protected $_code = 'customshippingrate';
protected $_isFixed = true;

Expand All @@ -39,19 +43,27 @@ public function collectRates(Mage_Shipping_Model_Rate_Request $request)
return false;
}

$result = Mage::getModel('shipping/rate_result');

$method = Mage::getModel('shipping/rate_result_method');

$method->setCarrier($this->_code);
$method->setCarrierTitle(Mage::helper('shipping')->__('Custom Carrier'));
$method->setCarrierTitle(Mage::helper('shipping')->__('Custom Carrier Title'));

$method->setMethod($this->_code);
$method->setMethodTitle(Mage::helper('shipping')->__('Custom Method'));
$method->setMethodTitle(Mage::helper('shipping')->__('Custom Method Title'));

$method->setPrice(0);
if (Mage::registry(self::SHIPPING_DESCRIPTION)) {
$method->setCarrierTitle(Mage::helper('shipping')->__(''));
$method->setMethodTitle(Mage::registry(self::SHIPPING_DESCRIPTION));
}

if (Mage::registry(self::BASE_SHIPPING_AMOUNT)) {
$method->setPrice(Mage::registry(self::BASE_SHIPPING_AMOUNT));
} else {
$method->setPrice(0);
}
$method->setCost(0);

$result = Mage::getModel('shipping/rate_result');
$result->append($method);

return $result;
Expand All @@ -64,7 +76,7 @@ public function collectRates(Mage_Shipping_Model_Rate_Request $request)
*/
public function getAllowedMethods()
{
return array('customshippingrate'=>Mage::helper('shipping')->__('Custom Shipping Rate'));
return array('customshippingrate' => Mage::helper('shipping')->__('Custom Shipping Rate'));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -29,29 +29,26 @@ class Indust_CustomShippingRate_Model_Quote_Address_Total_Shipping extends Mage_
*/
public function collect(Mage_Sales_Model_Quote_Address $address)
{
$_code = 'customshippingrate_customshippingrate';
if ($address->getShippingMethod() == 'customshippingrate_customshippingrate') {
$address->setCollectShippingRates(true); // force magento to recollect shipping rates because our form input from backend should be saved

$method = $address->getShippingMethod();

if ($method == $_code) {

$amountPrice = $address->getQuote()->getStore()->convertPrice($address->getBaseShippingAmount(), false);
if (Mage::helper('customshippingrate')->isMage13()) {
$address->setShippingAmount($amountPrice);
$address->setBaseShippingAmount($address->getBaseShippingAmount(), true);
$address->setGrandTotal($address->getGrandTotal() + $address->getShippingAmount());
$address->setBaseGrandTotal($address->getBaseGrandTotal() + $address->getBaseShippingAmount());
} else {
$this->_setAddress($address);
$this->_setAmount($amountPrice);
$this->_setBaseAmount($address->getBaseShippingAmount());
if ($address->getBaseShippingAmount() >= 0) { // when data is entered in backend order create
Mage::register(Indust_CustomShippingRate_Model_Carrier_Customshippingrate::BASE_SHIPPING_AMOUNT, $address->getBaseShippingAmount(), true);
} else { // when order is submitted in backend
Mage::register(Indust_CustomShippingRate_Model_Carrier_Customshippingrate::BASE_SHIPPING_AMOUNT, $address->getOrigData('base_shipping_amount'), true);
}
if ($address->getShippingAmount() >= 0) { // when data is entered in backend order create
Mage::register(Indust_CustomShippingRate_Model_Carrier_Customshippingrate::SHIPPING_AMOUNT, $address->getShippingAmount(), true);
} else { // when order is submitted in backend
Mage::register(Indust_CustomShippingRate_Model_Carrier_Customshippingrate::SHIPPING_AMOUNT, $address->getOrigData('shipping_amount'), true);
}
if ($address->getShippingDescription()) { // when data is entered in backend order create
Mage::register(Indust_CustomShippingRate_Model_Carrier_Customshippingrate::SHIPPING_DESCRIPTION, $address->getShippingDescription(), true);
} else { // when order is submitted in backend
Mage::register(Indust_CustomShippingRate_Model_Carrier_Customshippingrate::SHIPPING_DESCRIPTION, $address->getOrigData('shipping_description'), true);
}

return $this;
} else {
return parent::collect($address);
}

return parent::collect($address);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -29,40 +29,8 @@ class Indust_CustomShippingRate_Model_Sales_Order_Create extends Mage_Adminhtml_
*/
public function importPostData($data)
{
if (is_array($data)) {
$this->addData($data);
} else {
return $this;
}

if (isset($data['account'])) {
$this->setAccountData($data['account']);
}

if (isset($data['comment'])) {
$this->getQuote()->addData($data['comment']);
if (empty($data['comment']['customer_note_notify'])) {
$this->getQuote()->setCustomerNoteNotify(false);
} else {
$this->getQuote()->setCustomerNoteNotify(true);
}
}

if (isset($data['billing_address'])) {
$this->setBillingAddress($data['billing_address']);
}

if (isset($data['shipping_address'])) {
$this->setShippingAddress($data['shipping_address']);
}

if (isset($data['shipping_method'])) {
$this->setShippingMethod($data['shipping_method']);
}

if (isset($data['payment_method'])) {
$this->setPaymentMethod($data['payment_method']);
}
parent::importPostData($data);

if (isset($data['shipping_amount'])) {
$shippingPrice = $this->_parseShippingPrice($data['shipping_amount']);
Expand All @@ -78,16 +46,13 @@ public function importPostData($data)
$this->getQuote()->getShippingAddress()->setShippingDescription($data['shipping_description']);
}

if (isset($data['coupon']['code'])) {
$this->applyCoupon($data['coupon']['code']);
}
return $this;
}

protected function _parseShippingPrice($price)
{
$price = Mage::app()->getLocale()->getNumber($price);
$price = $price>0 ? $price : 0;
$price = $price > 0 ? $price : 0;
return $price;
}

Expand Down
7 changes: 5 additions & 2 deletions app/code/community/Indust/CustomShippingRate/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,17 @@
* @author BenRoe, ceefour
* @source https://github.com/bippo/customshippingrate-magento
* @version 1.5.2/1.5.3
* @author MaWoScha <mawoscha@siempro.co>
* @author MaWoScha
* @source https://github.com/MaWoScha/indust_customshippingrate
* @version 1.6.0
* @author ThomasNegeli
* @source https://github.com/ThomasNegeli/customshippingrate-magento
*/
-->
<config>
<modules>
<Indust_CustomShippingRate>
<version>1.5.3</version>
<version>1.6.1</version>
<depends>
<Mage_Shipping />
</depends>
Expand Down
55 changes: 54 additions & 1 deletion app/code/community/Indust/CustomShippingRate/etc/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,67 @@
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</active>
<name translate="label">
<label>Method Name</label>
<frontend_type>text</frontend_type>
<sort_order>3</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</name>
<sort_order translate="label">
<label>Sort Order</label>
<frontend_type>text</frontend_type>
<sort_order>9999</sort_order>
<sort_order>100</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>0</show_in_store>
</sort_order>
<title translate="label">
<label>Title</label>
<frontend_type>text</frontend_type>
<sort_order>2</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</title>
<sallowspecific translate="label">
<label>Ship to Applicable Countries</label>
<frontend_type>select</frontend_type>
<sort_order>90</sort_order>
<frontend_class>shipping-applicable-country</frontend_class>
<source_model>adminhtml/system_config_source_shipping_allspecificcountries</source_model>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>0</show_in_store>
</sallowspecific>
<specificcountry translate="label">
<label>Ship to Specific Countries</label>
<frontend_type>multiselect</frontend_type>
<sort_order>91</sort_order>
<source_model>adminhtml/system_config_source_country</source_model>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>0</show_in_store>
<can_be_empty>1</can_be_empty>
</specificcountry>
<showmethod translate="label">
<label>Show Method if Not Applicable</label>
<frontend_type>select</frontend_type>
<sort_order>92</sort_order>
<source_model>adminhtml/system_config_source_yesno</source_model>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>0</show_in_store>
</showmethod>
<specificerrmsg translate="label">
<label>Displayed Error Message</label>
<frontend_type>textarea</frontend_type>
<sort_order>80</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</specificerrmsg>
</fields>
</customshippingrate>
</groups>
Expand Down
5 changes: 5 additions & 0 deletions app/etc/modules/Indust_CustomShippingRate.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
<Indust_CustomShippingRate>
<active>true</active>
<codePool>community</codePool>
<depends>
<Mage_Shipping/>
<Mage_Sales/>
<Mage_Adminhtml/>
</depends>
</Indust_CustomShippingRate>
</modules>
</config>
Empty file modified app/locale/es_ES/Indust_CustomShippingRate.csv
100755 → 100644
Empty file.
Empty file modified app/locale/pt_PT/Indust_CustomShippingRate.csv
100755 → 100644
Empty file.
Loading

0 comments on commit 7aa7e2d

Please sign in to comment.