Wednesday, 15 September 2010

php - Opencart: How to get the code of a shipping method -



php - Opencart: How to get the code of a shipping method -

i developing shipping module of opencart.

i have reviewed source code of template shipping module below.

class="lang-html prettyprint-override"><?php foreach ($shipping_method['quote'] $quote) { ?> <tr class="highlight"> <td><?php if ($quote['code'] == $code || !$code) { ?> <?php $code = $quote['code']; ?> <input type="radio" name="shipping_method" value="<?php echo $quote['code']; ?>" id="<?php echo $quote['code']; ?>" checked="checked" /> <?php } else { ?> <input type="radio" name="shipping_method" value="<?php echo $quote['code']; ?>" id="<?php echo $quote['code']; ?>" /> <?php } ?></td> <td><label for="<?php echo $quote['code']; ?>"><?php echo $quote['title']; ?></label></td> <td style="text-align: right;"><label for="<?php echo $quote['code']; ?>"><?php echo $quote['text']; ?></label></td> </tr> <?php } ?>

however, not sure if adding new shipping method, should set/get $quote['code'].

shipping codes set in respective shipping method's model file, found in

/catalog/model/shipping/your_shipping_name.php

there number of methods come bundled opencart show how this. you'll want @ $quote_data variable in particular. it's worth noting if you're wanting have more 1 method type of shipping, such 24 hour, standard delivery etc gets little more complicated. here's example

$quote_data['surface'] = array( 'code' => 'royal_mail.surface', 'title' => $title, 'cost' => $cost, 'tax_class_id' => $this->config->get('royal_mail_tax_class_id'), 'text' => $this->currency->format($this->tax->calculate($cost, $this->config->get('royal_mail_tax_class_id'), $this->config->get('config_tax'))) );

this royal_mail.php file's shipping method (one of them). pay particular attending how code key has royal_mail followed . separate particular method surface. you'll notice surface array key quote in $quote_data. necessary distinguish between methods. example, should wish add together new shipping method called foo royal mail service shipping method, do

$quote_data['foo'] = array( 'code' => 'royal_mail.foo', 'title' => $title, 'cost' => $cost, 'tax_class_id' => $this->config->get('royal_mail_tax_class_id'), 'text' => $this->currency->format($this->tax->calculate($cost, $this->config->get('royal_mail_tax_class_id'), $this->config->get('config_tax'))) );

php opencart

No comments:

Post a Comment