Jump to content

How to disable some shipping methods for some products in All in One Shipping?


cubicsquare

Recommended Posts

Hi there,

Is there a way to disable some shipping methods for some products in the All in One Shipping extension or via some other means?

I have one method for bulky items sent economy. It is currently showing in the same pallette as, say, ordinary small parcels sent economy.

Obviously 99.5% of customers will opt for the cheaper ordinary small parcels economy tariff, rather than the twice as pricey bulky items eonomy tariff. However, if the item is, say, a chair, then i need to enforce the bulk tariff or at least block out the small parcels tariff.

 

 

Link to comment
Share on other sites

Do you want to enforce using 'bulk economy' for all items in the order, if any item in the order requires 'bulk economy'?

Or will you be using 'bulk economy' for only that item(s) that require it, while allowing the remaining items in the order to use 'small parcel economy'?

 

Link to comment
Share on other sites

Hi there, just for that item alone. I guess it's not doable with AIOS, because that only has one axis: Zone.

If people order multiple items no problem, it's keyed to weight.

The weight will reveal if there's a bulky policy possible. Even if the order is mixed (bulk + small package combined), so long as they paid bulky for one it's fine. 2 small items in combo will be anticipated correctly as regards their size, by my preset postage rates, i.e. 5kg + 5kg will be anticipated as a 10kg which in turn will be anticipated as a fairly bulky parcel anyways. That's the beauty of my existing system.

 

But for single items, i'd really like to enforce the "Bulky" tariff or at least block the "small parcel" tariff. I guess the only way is to add a second axis to AIOS, not just zones but also policies. The policy will be called "Bulky Only" and therefore will only have the "Bulky" method within its menu.

 

I'm guessing therefore it's not possible right now?

Link to comment
Share on other sites

Currently:

Imagine i'm selling a big sculpture made of coathanger wires. It is big, but doesn't actually weigh a lot. By the way l really think this is moot because l have no such stock but:

 

2kg item courier options:

> Small parcel (21x16x11cm): £FREE or £3.50 or sometihng cheap

> 1kg-10kg Bulky Tariff (50x50x60cm): £14.50

 

Of course the sculpture won't fit into a small parcel. But, 95.5% of customers will opt for the small parcel tariff. Myself included !!!

For my product "Coathanger Sculpture of Thinking Man" l need to:

> mute the small parcel tariff

and / or:

> Make visible only the 1kg-10kg Bulky Tariff

 

 

I guess it's not doable is it? Not with AIOS in its present form.

If the answer is indeed no, may l ask if there's a way l can play about with the code? I'm a complete stranger to coding but maybe l can pick it up just by looking at the existing code for the AIOS app?

 

Link to comment
Share on other sites

This is an interesting scenario to solve. I am asking for details so that efforts aren't proceeding to a misunderstood, unworkable solution.

As it currently sits in my brain, I want to use an otherwise unused product attribute (GTIN code? 'condition' recoded to "big" and "small"). When AIOS iterates across the basket contents, a flag can be set to invalidate certain other possible shipping choices.

Link to comment
Share on other sites

Good idea, but because there will be a variety of such makeshift GTIN codes (or whatever codes) we may as well call it by its real name: a second axis to AIOS, i.e. Shipping Policy (currently, AIOS is veeeeery linear).

 

Proposals for AIOS overhaul:

- Additional Axis: Shipping Weight Ranges (no need to re-type ranges for each new shipping method)

- Additional Axis: Shipping Policy (this is not a visible axis as such, it is basically a box of filing cards, on each filing card is written out your vertical list of Y-AXIS available shipping methods, and horizontal X-AXIS their cost at each weight range)

{ As an unnecessary extra: a checkbox next to each shipping method, allowing it to be muted, although alternatively of course you can just delete it manually, but then you lose the data you may have given for that shipping method within that shipping policy card, when in fact you might have wanted to be able to toggle it on and off at whim. }

 

- And this huge leap: somehow allow duplication of a shipping policy, though l don't know how that will be possible because obviously duplicating shipping data will affect the CubeCart databases and l'm not qualified to even say the word "database". I think l may be able to tinker with the other stuff l've just mentioned in this post.

 

Do you have some way l could view the AIOS app code or is it private? I don't mind really, it's not like l'll rustle up something within a few days or even years but it'd be nice to see if l could make a go of it. HTML was fairly easy to pick up and necessity drove me to learn basic HTML.

 

 

 

 

 

Link to comment
Share on other sites

The code to calculate a shipping price is easy enough to follow. See the file at /modules/shipping/All_In_One_Shipping/shipping.class.php. Find the public function calculate() and private function matching_rates().

I am currently working on a mod that will add a chooser to select any one of several possible product details to trigger an event that when there exists a product in the basket that requires a filtering of the otherwise possible shipping choices.

Link to comment
Share on other sites

For posterity here are the parts you mentioned in the previous post:

 

 

///////////////////////////PUBLIC FUNCTION CALCULATE PART OF THE PHP:

public function calculate() {
        $this->debugH('BASKET TOTALS');
        $this->debug(sprintf('Basket weight: %.3F', $this->_weight));
        $this->debug(sprintf('Basket value: %.2F', $this->_value));
        $this->debug(sprintf('Basket item count: %d', $this->_item_count));
 
        $zone_ids = $this->matching_zone_ids();
 
        $rates = $this->matching_rates($zone_ids);
 
        // CALCULATE PRICE FOR EACH SHIPPING METHOD
 
        $this->_package = array();
 
        for ($i=0; !empty($rates) && $i<count($rates); $i++) {
            $price = 0.0;
            if ($this->_settings['use_flat']) $price += $rates[$i]['flat_rate'];
            if ($this->_settings['use_weight']) $price += $rates[$i]['weight_rate'] * $this->_weight;
            if ($this->_settings['use_item']) $price += $rates[$i]['item_rate'] * $this->_item_count;
            if ($this->_settings['use_percent']) $price += $rates[$i]['percent_rate']/100 * $this->_value;
 
            $this->_package[] = array(
                'name'      => $rates[$i]['method_name'],
                'value'     => sprintf('%.2F', $price),
                'tax_id'    => (int)$this->_settings['tax'],
                'tax_inclusive'    => (int)$this->_settings['tax_included'],
                ## Delivery times not applicable to this module
                'shipping'  => '',
                'delivery'  => '',
                'next_day'  => ''
            );
        }
 
        if (!empty($this->_package)) {
            $this->debugH('FINAL SHIPPING OPTIONS FOR THIS ADDRESS AND BASKET');
            foreach ($this->_package as $p)
                $this->debug(sprintf('%s: %s', $p['name'], $p['value']));
        } else {
            $this->debugH('<strong>All In One Shipping module has no shipping options for this address and basket!</strong>');
        }
 
        $this->echo_debug();
 
        return !empty($this->_package) ? $this->_package : false;
    }

 

 

///////////////////////////PRIVATE FUNCTION MATCHING RATES PART OF THE PHP:

 

    private function matching_rates($zone_ids) {
 
        if (!is_array($zone_ids)) {
            return array();
        }
 
        $this->debugH('SHIPPING RATES');
        $this->debug('All rates:', $debug_level=2);
        $this->debug('<pre>'.print_r($this->_all_rates, true).'</pre>', $debug_level=2);
        $this->debug(sprintf('Looking at the shipping rates for zone(s) [ID %s]', implode(', ',$zone_ids)));
 
        // resulting matching rates (if any)
        $rates = array();
 
        $count = count($this->_all_rates);
        for ($i=0; !empty($this->_all_rates) && $i<$count; $i++) {
 
            $r = $this->_all_rates[$i];
 
            if (in_array($r['zone_id'], $zone_ids)) {
 
                $ok = true;
 
                if ($this->_settings['range_weight']) {
                    if ($this->_weight < $r['min_weight'] && $r['min_weight'] > 0) {
                        $ok = false;
                    } else if ($this->_weight > $r['max_weight'] && $r['max_weight'] > 0) {
                        $ok = false;
                    }
                    if (!$ok) $this->debug(sprintf('Rate [ID: %d] [%s] --- Weight range [%s &lt; weight &lt;= %s] doesn\'t match basket weight [%s]', $r['id'], $r['method_name'], $r['min_weight'], $r['max_weight'], $this->_weight));
                }
                if ($ok && $this->_settings['range_subtotal']) {
                    if ($this->_value <= $r['min_value'] && $r['min_value'] > 0) {
                        $ok = false;
                    } else if ($this->_value > $r['max_value'] && $r['max_value'] > 0) {
                        $ok = false;
                    }
                    if (!$ok) $this->debug(sprintf('Rate [ID: %d] [%s] --- Subtotal range [%s &lt; subtotal &lt;= %s] doesn\'t match basket subtotal [%s]', $r['id'], $r['method_name'], $r['min_value'], $r['max_value'], $this->_value));
                }
                if ($ok && $this->_settings['range_items']) {
                    if ($this->_item_count < $r['min_items'] && $r['min_items'] > 0) {
                        $ok = false;
                    } else if ($this->_item_count > $r['max_items'] && $r['max_items'] > 0) {
                        $ok = false;
                    }
                    if (!$ok) $this->debug(sprintf('Rate [ID: %d] [%s] --- Total Quantity range [%s &lt; total quantity &lt; %s] doesn\'t match basket total quantity [%s]', $r['id'], $r['method_name'], $r['min_items'], $r['max_items'], $this->_item_count));
                }
 
                if ($ok) {
                    $this->debug(sprintf('Rate [ID: %d] [%s] --- <strong> Shipping rate is valid for this basket!</strong>', $r['id'], $r['method_name']));
                    $rates[] = $r;
                }
            }
        }
 
        return $rates;

 

 

 

 

 

16 minutes ago, cubicsquare said:

       if (!is_array($zone_ids)) {
            return array();

 

Bearing in mind this is my first ever real look at PhP (l just Googled 1 minute ago, apparently it's a programming language all in itself), l would zoom in on the above 2-line quoted part, and add a caveat about the GTIN field, in a series of nested "if" statements, one per shipping policy to be denoted by a GTIN field.

Each nested "if" statement would exclude the shipping methods named in that GTIN field, period, regardless the weight band.

 

Of course it would be problematic if you just wanted to give freepost for a specific weight band under a specific Shipping Method but that's rabbit holes for yer, l think the main thing is that your method is powerful because there's no need to redefine each of the >25 shipping zones l have, per shipping policy.

 

Instead, the GTIN code would treat Shipping Policies as a gentle post edit. And it won't necessarily delete an entire row of data, it would just mute it. So l think that's quite a deft move - l hope it works out for you.

 

I hope you alert the forum of any versions you produce , even if just for testing, l'd be interested.

 

 

 

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...