Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I recently work on similar type of requirement. so follow my instructions:-</p> <p><strong>I request to you that don't focus on the length of answer just focus on the result</strong></p> <p><strong>step 1</strong>:-if you want to put Driver tip between shipping and shipping method then first open</p> <p>\app\code\core\Mage\Checkout\Block\Onepage.php there is an array $stepCodes (line no:- 44). replace that with this</p> <pre><code>$stepCodes = array('billing', 'shipping', 'excellence2','shipping_method', 'payment', 'review'); </code></pre> <p>i am using <strong>excellence2</strong> you can also use this name. </p> <p><strong>Step 2</strong>:- now we need to create Excellence2 class on app\code\core\Mage\Checkout\Block\Onepage\ so create a new php file and put that code into it and save as Excellence2.php </p> <pre><code>class Mage_Checkout_Block_Onepage_Excellence2 extends Mage_Checkout_Block_Onepage_Abstract { protected function _construct() { $this-&gt;getCheckout()-&gt;setStepData('excellence2', array( 'label' =&gt; Mage::helper('checkout')-&gt;__('Tip Ammount'), 'is_show' =&gt; $this-&gt;isShow() )); parent::_construct(); } } </code></pre> <p><strong>Note</strong>:- now you can put any name at label of _construct() function so change <strong>'Tip Ammount'</strong> to <strong>Driver tip</strong></p> <p><strong>Step 3</strong>:-now open <strong>OnepageController.php</strong> which is located in app\code\core\Mage\Checkout\controllers\ and find <strong>saveBillingAction()</strong> function (line no:-296) and replace that code by this</p> <pre><code> public function saveBillingAction() { if ($this-&gt;_expireAjax()) { return; } if ($this-&gt;getRequest()-&gt;isPost()) { // $postData = $this-&gt;getRequest()-&gt;getPost('billing', array()); // $data = $this-&gt;_filterPostData($postData); $data = $this-&gt;getRequest()-&gt;getPost('billing', array()); $customerAddressId = $this-&gt;getRequest()-&gt;getPost('billing_address_id', false); if (isset($data['email'])) { $data['email'] = trim($data['email']); } $result = $this-&gt;getOnepage()-&gt;saveBilling($data, $customerAddressId); if (!isset($result['error'])) { /* check quote for virtual */ if ($this-&gt;getOnepage()-&gt;getQuote()-&gt;isVirtual()) { $result['goto_section'] = 'payment'; $result['update_section'] = array( 'name' =&gt; 'payment-method', 'html' =&gt; $this-&gt;_getPaymentMethodsHtml() ); } elseif (isset($data['use_for_shipping']) &amp;&amp; $data['use_for_shipping'] == 1) { $result['goto_section'] = 'excellence2'; //Goes to our step $result['allow_sections'] = array('shipping'); $result['duplicateBillingInfo'] = 'true'; } else { $result['goto_section'] = 'shipping'; } } $this-&gt;getResponse()-&gt;setBody(Mage::helper('core')-&gt;jsonEncode($result)); } } </code></pre> <p><strong>Step 4</strong>:- again in same file <strong>OnepageController.php</strong> there is a saveShippingAction() function (line no 331) change this to </p> <pre><code> public function saveShippingAction() { if ($this-&gt;_expireAjax()) { return; } if ($this-&gt;getRequest()-&gt;isPost()) { $data = $this-&gt;getRequest()-&gt;getPost('shipping', array()); $customerAddressId = $this-&gt;getRequest()-&gt;getPost('shipping_address_id', false); $result = $this-&gt;getOnepage()-&gt;saveShipping($data, $customerAddressId); if (!isset($result['error'])) { $result['goto_section'] = 'excellence2'; //Go to our step } $this-&gt;getResponse()-&gt;setBody(Mage::helper('core')-&gt;jsonEncode($result)); } } </code></pre> <p>this code tells that when user pass though the shipping step then he will go to our <strong>Driver tip</strong> step.</p> <p><strong>Step 5</strong>:-again in same file (<strong>OnepageController.php</strong>) we need to tell that where user will redirect after pass though <strong>Driver tip</strong> step .so create a saveExcellence2Action() just after saveShippingAction() function </p> <pre><code>public function saveExcellence2Action() { if ($this-&gt;_expireAjax()) { return; } if ($this-&gt;getRequest()-&gt;isPost()) { $data = $this-&gt;getRequest()-&gt;getPost('excellence2', array()); $result = $this-&gt;getOnepage()-&gt;saveExcellence2($data); if (!isset($result['error'])) { $result['goto_section'] = 'shipping_method'; $result['update_section'] = array( 'name' =&gt; 'shipping-method', 'html' =&gt; $this-&gt;_getShippingMethodsHtml() ); } $this-&gt;getResponse()-&gt;setBody(Mage::helper('core')-&gt;jsonEncode($result)); } } </code></pre> <p><strong>Step 6</strong>:- now we change in checkout.xml which is located in </p> <p>\app\design\frontend\default\your template\layout open it and find </p> <pre><code>&lt;checkout_onepage_index translate="label"&gt; </code></pre> <p>and in that particular node there is block (line no 326)</p> <pre><code>&lt;block type="checkout/onepage_shipping" name="checkout.onepage.shipping" as="shipping" template="checkout/onepage/shipping.phtml"/&gt; </code></pre> <p>just add a new block after this line shown above</p> <pre><code>&lt;block type="checkout/onepage_excellence2" name="checkout.onepage.excellence2" as="excellence2" template="checkout/onepage/excellence2.phtml"/&gt; </code></pre> <p><strong>Step 7</strong>:- now we need to create a <strong>excellence2.phtml</strong> file at \app\design\frontend\default\your template\template\checkout\onepage\</p> <p>this file show the content which you want to show to user</p> <pre><code>&lt;form id="co-excellence2-form" action=""&gt; &lt;div class="wide"&gt; &lt;label for="excellence2:like" class="required"&gt;&lt;em style="color:#F00;"&gt;*&lt;/em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Select the amount of tip ,You wish to give to the driver.&lt;/label&gt; &lt;/div&gt; &lt;div style="margin-top:20px;"&gt; &lt;ul&gt; &lt;li&gt; &lt;input type="radio" name="excellence2[like]" id="excellence2:like" value="0" checked="checked" class="radio" onclick="savevalue(this.value);"/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;No Tip/Pay driver at the door &lt;/li&gt; &lt;li&gt; &lt;input type="radio" name="excellence2[like]" id="excellence2:like" value="150" class="radio" onclick="savevalue(this.value);" /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;150$ &lt;/li&gt; &lt;li&gt; &lt;input type="radio" name="excellence2[like]" id="excellence2:like" value="250" class="radio" onclick="savevalue(this.value);"/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;250$ &lt;/li&gt; &lt;li&gt; &lt;input type="radio" name="excellence2[like]" id="excellence2:like" value="400" class="radio" onclick="savevalue(this.value);" /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;400$ &lt;/li&gt; &lt;li&gt; &lt;input type="radio" name="excellence2[like]" id="excellence2:like" value="500" class="radio" onclick="savevalue(this.value);"/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;500$ &lt;/li&gt; &lt;li&gt; &lt;input type="radio" name="excellence2[like]" id="excellence2:like" value="15% of total amount" class="radio" onclick="savevalue(this.value);" /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;15% of Total Amount &lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;fieldset&gt; &lt;div class="buttons-set" id="excellence2-buttons-container"&gt; &lt;p class="required"&gt;&lt;?php echo $this-&gt;__('* Required Fields') ?&gt;&lt;/p&gt; &lt;button type="button" title="&lt;?php echo $this-&gt;__('Continue') ?&gt;" class="button" onclick="excellence2.save()"&gt;&lt;span&gt;&lt;span&gt;&lt;?php echo $this-&gt;__('Continue') ?&gt;&lt;/span&gt;&lt;/span&gt; &lt;/button&gt; &lt;span class="please-wait" id="excellence2-please-wait" style="display:none;"&gt; &lt;img src="&lt;?php echo $this-&gt;getSkinUrl('images/opc-ajax-loader.gif') ?&gt;" alt="&lt;?php echo $this-&gt;__('Loading next step...') ?&gt;" title="&lt;?php echo $this-&gt;__('Loading next step...') ?&gt;" class="v-middle" /&gt; &lt;?php echo $this-&gt;__('Loading next step...') ?&gt; &lt;/span&gt; &lt;/div&gt; &lt;/fieldset&gt; &lt;/form&gt; &lt;script type="text/javascript"&gt; //&lt;![CDATA[ var excellence2 = new ExcellenceMethod2('co-excellence2-form','&lt;?php echo $this-&gt;getUrl('checkout/onepage/saveExcellence2') ?&gt;'); var excellenceForm2 = new VarienForm('co-excellence2-form'); //]]&gt; &lt;/script&gt; </code></pre> <p><strong>Step 8</strong>:-now we need to create a <strong>excellencecheckout.js</strong> file at \skin\frontend\default\your template\js</p> <pre><code>var ExcellenceMethod2 = Class.create(); ExcellenceMethod2.prototype = { initialize: function(form, saveUrl){ this.form = form; if ($(this.form)) { $(this.form).observe('submit', function(event){this.save();Event.stop(event);}.bind(this)); } this.saveUrl = saveUrl; this.validator = new Validation(this.form); this.onSave = this.nextStep.bindAsEventListener(this); this.onComplete = this.resetLoadWaiting.bindAsEventListener(this); }, validate: function() { return true; }, save: function(){ //alert('hi'); if (checkout.loadWaiting!=false) return; if (this.validate()) { checkout.setLoadWaiting('excellence2'); var request = new Ajax.Request( this.saveUrl, { method:'post', onComplete: this.onComplete, onSuccess: this.onSave, onFailure: checkout.ajaxFailure.bind(checkout), parameters: Form.serialize(this.form) } ); } }, resetLoadWaiting: function(transport){ checkout.setLoadWaiting(false); }, nextStep: function(transport){ if (transport &amp;&amp; transport.responseText){ try{ response = eval('(' + transport.responseText + ')'); } catch (e) { response = {}; } } if (response.error) { alert(response.message); return false; } if (response.update_section) { $('checkout-'+response.update_section.name+'-load').update(response.update_section.html); } if (response.goto_section) { //alert(response); checkout.gotoSection(response.goto_section); checkout.reloadProgressBlock(); return; } checkout.setPayment(); } } </code></pre> <p><strong>Step 9</strong>:- now we need to create a new function for save data which user was selected . so we are creating new function which name is <strong>saveExcellence2()</strong> just after the saveShipping($data, $customerAddressId) finction in Onepage.php which is located in \app\code\core\Mage\Checkout\Model\Type\</p> <pre><code>public function saveExcellence2($data) { if (empty($data)) { return array('error' =&gt; -1, 'message' =&gt; $this-&gt;_helper-&gt;__('Invalid data.')); } $this-&gt;getQuote()-&gt;setExcellenceLike2($data['like']); $this-&gt;getQuote()-&gt;collectTotals(); $this-&gt;getQuote()-&gt;save(); $this-&gt;getCheckout() -&gt;setStepData('excellence2', 'complete', true) -&gt;setStepData('shipping_method', 'allow', true); return array(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload