Version Notes
Removing all the licensing requirements.
Download this release
Release Info
Developer | Arron Moss |
Extension | Zero1_Customshipprice |
Version | 1.0.0 |
Comparing to | |
See all releases |
Version 1.0.0
- app/code/community/Zero1/Customshipprice/Helper/Data.php +4 -0
- app/code/community/Zero1/Customshipprice/Model/Adminhtml/Sales/Order/Create.php +92 -0
- app/code/community/Zero1/Customshipprice/Model/Carrier/Customshipprice.php +57 -0
- app/code/community/Zero1/Customshipprice/etc/config.xml +57 -0
- app/code/community/Zero1/Customshipprice/etc/system.xml +115 -0
- app/etc/modules/Zero1_Customshipprice.xml +9 -0
- package.xml +19 -0
app/code/community/Zero1/Customshipprice/Helper/Data.php
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Zero1_Customshipprice_Helper_Data extends Mage_Core_Helper_Abstract
|
3 |
+
{
|
4 |
+
}
|
app/code/community/Zero1/Customshipprice/Model/Adminhtml/Sales/Order/Create.php
ADDED
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Zero1_Customshipprice_Model_Adminhtml_Sales_Order_Create extends Mage_Adminhtml_Model_Sales_Order_Create
|
3 |
+
{
|
4 |
+
/**
|
5 |
+
* Parse data retrieved from request
|
6 |
+
*
|
7 |
+
* @param array $data
|
8 |
+
* @return Mage_Adminhtml_Model_Sales_Order_Create
|
9 |
+
*/
|
10 |
+
public function importPostData($data)
|
11 |
+
{
|
12 |
+
if (is_array($data)) {
|
13 |
+
$this->addData($data);
|
14 |
+
} else {
|
15 |
+
return $this;
|
16 |
+
}
|
17 |
+
|
18 |
+
if (isset($data['account'])) {
|
19 |
+
$this->setAccountData($data['account']);
|
20 |
+
}
|
21 |
+
|
22 |
+
if (isset($data['comment'])) {
|
23 |
+
$this->getQuote()->addData($data['comment']);
|
24 |
+
if (empty($data['comment']['customer_note_notify'])) {
|
25 |
+
$this->getQuote()->setCustomerNoteNotify(false);
|
26 |
+
} else {
|
27 |
+
$this->getQuote()->setCustomerNoteNotify(true);
|
28 |
+
}
|
29 |
+
}
|
30 |
+
|
31 |
+
if (isset($data['billing_address'])) {
|
32 |
+
$this->setBillingAddress($data['billing_address']);
|
33 |
+
}
|
34 |
+
|
35 |
+
if (isset($data['shipping_address'])) {
|
36 |
+
$this->setShippingAddress($data['shipping_address']);
|
37 |
+
}
|
38 |
+
|
39 |
+
if (isset($data['shipping_method'])) {
|
40 |
+
$this->setShippingMethod($data['shipping_method']);
|
41 |
+
}
|
42 |
+
|
43 |
+
if (isset($data['payment_method'])) {
|
44 |
+
$this->setPaymentMethod($data['payment_method']);
|
45 |
+
}
|
46 |
+
|
47 |
+
$reinit_rates = false;
|
48 |
+
|
49 |
+
if (isset($data['shipping_amount'])) {
|
50 |
+
$shippingPrice = $this->_parseShippingPrice($data['shipping_amount']);
|
51 |
+
//$this->getQuote()->getShippingAddress()->setShippingAmount($shippingPrice);
|
52 |
+
Mage::getSingleton('core/session')->setCustomshippriceAmount($shippingPrice);
|
53 |
+
$reinit_rates = true;
|
54 |
+
}
|
55 |
+
|
56 |
+
if (isset($data['base_shipping_amount'])) {
|
57 |
+
$baseShippingPrice = $this->_parseShippingPrice($data['base_shipping_amount']);
|
58 |
+
//$this->getQuote()->getShippingAddress()->setBaseShippingAmount($baseShippingPrice, true);
|
59 |
+
Mage::getSingleton('core/session')->setCustomshippriceBaseAmount($baseShippingPrice);
|
60 |
+
$reinit_rates = true;
|
61 |
+
}
|
62 |
+
|
63 |
+
if (isset($data['shipping_description'])) {
|
64 |
+
//$this->getQuote()->getShippingAddress()->setShippingDescription($data['shipping_description']);
|
65 |
+
Mage::getSingleton('core/session')->setCustomshippriceDescription($data['shipping_description']);
|
66 |
+
$reinit_rates = true;
|
67 |
+
}
|
68 |
+
|
69 |
+
if (isset($data['coupon']['code'])) {
|
70 |
+
$this->applyCoupon($data['coupon']['code']);
|
71 |
+
$reinit_rates = true;
|
72 |
+
}
|
73 |
+
|
74 |
+
if($reinit_rates)
|
75 |
+
{
|
76 |
+
//$this->collectShippingRates();
|
77 |
+
//$this->getQuote()->getShippingAddress()->setCollectShippingRates(true);
|
78 |
+
//$this->collectRates();
|
79 |
+
//$this->getQuote()->collectTotals();
|
80 |
+
}
|
81 |
+
|
82 |
+
return $this;
|
83 |
+
}
|
84 |
+
|
85 |
+
protected function _parseShippingPrice($price)
|
86 |
+
{
|
87 |
+
$price = Mage::app()->getLocale()->getNumber($price);
|
88 |
+
$price = $price>0 ? $price : 0;
|
89 |
+
return $price;
|
90 |
+
}
|
91 |
+
|
92 |
+
}
|
app/code/community/Zero1/Customshipprice/Model/Carrier/Customshipprice.php
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Zero1_Customshipprice_Model_Carrier_Customshipprice
|
3 |
+
extends Mage_Shipping_Model_Carrier_Abstract
|
4 |
+
implements Mage_Shipping_Model_Carrier_Interface
|
5 |
+
{
|
6 |
+
|
7 |
+
protected $_code = 'customshipprice';
|
8 |
+
protected $_isFixed = false;
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Enter description here...
|
12 |
+
*
|
13 |
+
* @param Mage_Shipping_Model_Rate_Request $data
|
14 |
+
* @return Mage_Shipping_Model_Rate_Result
|
15 |
+
*/
|
16 |
+
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
|
17 |
+
{
|
18 |
+
if(!Mage::app()->getStore()->isAdmin()) {
|
19 |
+
return false; // Only allow this to be used from the admin system
|
20 |
+
}
|
21 |
+
|
22 |
+
if (!$this->getConfigFlag('active')) {
|
23 |
+
return false;
|
24 |
+
}
|
25 |
+
|
26 |
+
$result = Mage::getModel('shipping/rate_result');
|
27 |
+
|
28 |
+
$shippingPrice = Mage::getSingleton('core/session')->getCustomshippriceAmount();
|
29 |
+
$baseShippingPrice = Mage::getSingleton('core/session')->getCustomshippriceBaseAmount();
|
30 |
+
$description = Mage::getSingleton('core/session')->getCustomshippriceDescription();
|
31 |
+
|
32 |
+
$shippingPrice = $this->getFinalPriceWithHandlingFee($shippingPrice);
|
33 |
+
|
34 |
+
if ($shippingPrice !== false) {
|
35 |
+
$method = Mage::getModel('shipping/rate_result_method');
|
36 |
+
|
37 |
+
$method->setCarrier('customshipprice');
|
38 |
+
$method->setCarrierTitle($this->getConfigData('title'));
|
39 |
+
|
40 |
+
$method->setMethod('customshipprice');
|
41 |
+
$method->setMethodTitle((strlen($description) > 0) ? $description : $this->getConfigData('name'));
|
42 |
+
|
43 |
+
$method->setPrice($shippingPrice);
|
44 |
+
$method->setCost($shippingPrice);
|
45 |
+
|
46 |
+
$result->append($method);
|
47 |
+
}
|
48 |
+
|
49 |
+
return $result;
|
50 |
+
}
|
51 |
+
|
52 |
+
public function getAllowedMethods()
|
53 |
+
{
|
54 |
+
return array('customshipprice'=>$this->getConfigData('name'));
|
55 |
+
}
|
56 |
+
|
57 |
+
}
|
app/code/community/Zero1/Customshipprice/etc/config.xml
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Zero1_Customshipprice>
|
5 |
+
<version>1.0.0.0</version>
|
6 |
+
</Zero1_Customshipprice>
|
7 |
+
</modules>
|
8 |
+
|
9 |
+
<global>
|
10 |
+
<models>
|
11 |
+
<customshipprice>
|
12 |
+
<class>Zero1_Customshipprice_Model</class>
|
13 |
+
</customshipprice>
|
14 |
+
|
15 |
+
<adminhtml>
|
16 |
+
<rewrite>
|
17 |
+
<sales_order_create>Zero1_Customshipprice_Model_Adminhtml_Sales_Order_Create</sales_order_create>
|
18 |
+
</rewrite>
|
19 |
+
</adminhtml>
|
20 |
+
</models>
|
21 |
+
|
22 |
+
<blocks>
|
23 |
+
<customshipprice>
|
24 |
+
<class>Zero1_Customshipprice_Block</class>
|
25 |
+
</customshipprice>
|
26 |
+
</blocks>
|
27 |
+
|
28 |
+
<helpers>
|
29 |
+
<customshipprice>
|
30 |
+
<class>Zero1_Customshipprice_Helper</class>
|
31 |
+
</customshipprice>
|
32 |
+
</helpers>
|
33 |
+
</global>
|
34 |
+
|
35 |
+
<adminhtml>
|
36 |
+
<layout>
|
37 |
+
<updates>
|
38 |
+
<customshipprice>
|
39 |
+
<file>customshipprice.xml</file>
|
40 |
+
</customshipprice>
|
41 |
+
</updates>
|
42 |
+
</layout>
|
43 |
+
</adminhtml>
|
44 |
+
|
45 |
+
<default>
|
46 |
+
<carriers>
|
47 |
+
<customshipprice>
|
48 |
+
<active>0</active>
|
49 |
+
<sallowspecific>0</sallowspecific>
|
50 |
+
<model>customshipprice/carrier_customshipprice</model>
|
51 |
+
<name>Custom Shipping Price</name>
|
52 |
+
<title>Custom Shipping Price</title>
|
53 |
+
<specificerrmsg>This shipping method is currently unavailable. If you would like to ship using this shipping method, please contact us.</specificerrmsg>
|
54 |
+
</customshipprice>
|
55 |
+
</carriers>
|
56 |
+
</default>
|
57 |
+
</config>
|
app/code/community/Zero1/Customshipprice/etc/system.xml
ADDED
@@ -0,0 +1,115 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* Magento
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
9 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://opensource.org/licenses/afl-3.0.php
|
12 |
+
* If you did not receive a copy of the license and are unable to
|
13 |
+
* obtain it through the world-wide-web, please send an email
|
14 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
15 |
+
*
|
16 |
+
* DISCLAIMER
|
17 |
+
*
|
18 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
19 |
+
* versions in the future. If you wish to customize Magento for your
|
20 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
21 |
+
*
|
22 |
+
* @category Mage
|
23 |
+
* @package Mage_Shipping
|
24 |
+
* @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
|
25 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
26 |
+
*/
|
27 |
+
-->
|
28 |
+
<config>
|
29 |
+
<sections>
|
30 |
+
<carriers translate="label" module="shipping">
|
31 |
+
<groups>
|
32 |
+
<customshipprice translate="label">
|
33 |
+
<label>Custom Shipping Price</label>
|
34 |
+
<frontend_type>text</frontend_type>
|
35 |
+
<sort_order>2</sort_order>
|
36 |
+
<show_in_default>1</show_in_default>
|
37 |
+
<show_in_website>1</show_in_website>
|
38 |
+
<show_in_store>1</show_in_store>
|
39 |
+
<fields>
|
40 |
+
<active translate="label">
|
41 |
+
<label>Enabled</label>
|
42 |
+
<frontend_type>select</frontend_type>
|
43 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
44 |
+
<sort_order>1</sort_order>
|
45 |
+
<show_in_default>1</show_in_default>
|
46 |
+
<show_in_website>1</show_in_website>
|
47 |
+
<show_in_store>0</show_in_store>
|
48 |
+
</active>
|
49 |
+
<name translate="label">
|
50 |
+
<label>Method Name</label>
|
51 |
+
<frontend_type>text</frontend_type>
|
52 |
+
<sort_order>3</sort_order>
|
53 |
+
<show_in_default>1</show_in_default>
|
54 |
+
<show_in_website>1</show_in_website>
|
55 |
+
<show_in_store>1</show_in_store>
|
56 |
+
</name>
|
57 |
+
<sort_order translate="label">
|
58 |
+
<label>Sort Order</label>
|
59 |
+
<frontend_type>text</frontend_type>
|
60 |
+
<sort_order>100</sort_order>
|
61 |
+
<show_in_default>1</show_in_default>
|
62 |
+
<show_in_website>1</show_in_website>
|
63 |
+
<show_in_store>0</show_in_store>
|
64 |
+
</sort_order>
|
65 |
+
<title translate="label">
|
66 |
+
<label>Title</label>
|
67 |
+
<frontend_type>text</frontend_type>
|
68 |
+
<sort_order>2</sort_order>
|
69 |
+
<show_in_default>1</show_in_default>
|
70 |
+
<show_in_website>1</show_in_website>
|
71 |
+
<show_in_store>1</show_in_store>
|
72 |
+
</title>
|
73 |
+
<sallowspecific translate="label">
|
74 |
+
<label>Ship to Applicable Countries</label>
|
75 |
+
<frontend_type>select</frontend_type>
|
76 |
+
<sort_order>90</sort_order>
|
77 |
+
<frontend_class>shipping-applicable-country</frontend_class>
|
78 |
+
<source_model>adminhtml/system_config_source_shipping_allspecificcountries</source_model>
|
79 |
+
<show_in_default>1</show_in_default>
|
80 |
+
<show_in_website>1</show_in_website>
|
81 |
+
<show_in_store>0</show_in_store>
|
82 |
+
</sallowspecific>
|
83 |
+
<specificcountry translate="label">
|
84 |
+
<label>Ship to Specific Countries</label>
|
85 |
+
<frontend_type>multiselect</frontend_type>
|
86 |
+
<sort_order>91</sort_order>
|
87 |
+
<source_model>adminhtml/system_config_source_country</source_model>
|
88 |
+
<show_in_default>1</show_in_default>
|
89 |
+
<show_in_website>1</show_in_website>
|
90 |
+
<show_in_store>0</show_in_store>
|
91 |
+
<can_be_empty>1</can_be_empty>
|
92 |
+
</specificcountry>
|
93 |
+
<showmethod translate="label">
|
94 |
+
<label>Show Method if Not Applicable</label>
|
95 |
+
<frontend_type>select</frontend_type>
|
96 |
+
<sort_order>92</sort_order>
|
97 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
98 |
+
<show_in_default>1</show_in_default>
|
99 |
+
<show_in_website>1</show_in_website>
|
100 |
+
<show_in_store>0</show_in_store>
|
101 |
+
</showmethod>
|
102 |
+
<specificerrmsg translate="label">
|
103 |
+
<label>Displayed Error Message</label>
|
104 |
+
<frontend_type>textarea</frontend_type>
|
105 |
+
<sort_order>80</sort_order>
|
106 |
+
<show_in_default>1</show_in_default>
|
107 |
+
<show_in_website>1</show_in_website>
|
108 |
+
<show_in_store>1</show_in_store>
|
109 |
+
</specificerrmsg>
|
110 |
+
</fields>
|
111 |
+
</customshipprice>
|
112 |
+
</groups>
|
113 |
+
</carriers>
|
114 |
+
</sections>
|
115 |
+
</config>
|
app/etc/modules/Zero1_Customshipprice.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Zero1_Customshipprice>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>community</codePool>
|
7 |
+
</Zero1_Customshipprice>
|
8 |
+
</modules>
|
9 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Zero1_Customshipprice</name>
|
4 |
+
<version>1.0.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="http://shop.zero1.co.uk/LICENSE.txt">Commercial</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Set a custom shipping price in Admin for orders</summary>
|
10 |
+
<description>Allows a custom shipping price to be entered into the admin system when placing orders.</description>
|
11 |
+
<notes>Removing all the licensing requirements.
|
12 |
+
</notes>
|
13 |
+
<authors><author><name>Arron Moss</name><user>zero1limited</user><email>arron.moss@zero1.co.uk</email></author></authors>
|
14 |
+
<date>2013-03-21</date>
|
15 |
+
<time>21:35:09</time>
|
16 |
+
<contents><target name="magecommunity"><dir name="Zero1"><dir name="Customshipprice"><dir name="Helper"><file name="Data.php" hash="ba9c722115a8371684a3a1955af2b88a"/></dir><dir name="Model"><dir name="Adminhtml"><dir name="Sales"><dir name="Order"><file name="Create.php" hash="f642fc1a7450929ce77e0668c2a1c94d"/></dir></dir></dir><dir name="Carrier"><file name="Customshipprice.php" hash="888632345045787c44ed435969573996"/></dir></dir><dir name="etc"><file name="config.xml" hash="2f7fa5f9dfdc89991db82a4a07807755"/><file name="system.xml" hash="7219383cace47f7a86ce10f8bc552638"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Zero1_Customshipprice.xml" hash="69e1410bd9095aa1fdc387ca88fa572f"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="customshipprice.xml" hash=""/></dir></dir></dir></dir></target></contents>
|
17 |
+
<compatible/>
|
18 |
+
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
19 |
+
</package>
|