Page 1 of 1

Question on session shipping

Posted: Thu Mar 14, 2024 3:08 pm
by Pierre_P
Just a why question i need to know that i am wandering on perhaps confusing.

if i do this on the checkout_payment.php page

Code: Select all

echo $_SESSION['shipping']['id'];
it will example echo flat_flat
Why not just echo flat? Does it use the class name or?
I do see where the underscore is used in this strpos like

Code: Select all

substr($_SESSION['shipping']['id'], 0, strpos($_SESSION['shipping']['id'], '_'));
Any explanations pls.

Re: Question on session shipping

Posted: Thu Mar 14, 2024 4:15 pm
by burt
I think no particular reason why, other than the fact that this is what osCommerce did.
It's just never been looked at for a recode, as it "works".

Re: Question on session shipping

Posted: Thu Mar 14, 2024 7:04 pm
by raiwa
I think this is used for to define shipping for modules which have several methods. The first part identifies the module and the second part the method. For shipping modules which do not use methods, like flat, the resulting combination repeats the module name for the method part.
This is also the reason that it is not allowed to use underscore in the shipping module name.

Re: Question on session shipping

Posted: Fri Mar 15, 2024 1:33 am
by ecartz
Pierre_P wrote: Thu Mar 14, 2024 3:08 pm Why not just echo flat?
One shipping module can offer multiple methods. For flat, there's only one method, so flat_flat. But you could have

ups_ground
ups_nextday

or similar. It's just that all the core shipping modules are simpler than that.

Re: Question on session shipping

Posted: Fri Mar 15, 2024 5:32 am
by Pierre_P
ecartz wrote: Fri Mar 15, 2024 1:33 am One shipping module can offer multiple methods. For flat, there's only one method, so flat_flat. But you could have

ups_ground
ups_nextday

or similar. It's just that all the core shipping modules are simpler than that.
Thanks for all the clarifications as this makes most sense.
I do record the shipping module used in the orders table and also using this to disable certain payment options for example if you select courier option then my store would disable the in store payment module cod(brick building).
This way it would eliminate following up sending bank payment details and many more complications.

To expand on your multiple methods example ups_ground would it be as simple to add and change 'id' => $this->code, to 'id' => $service_code = $rate['service_level']['code'], in the following then i can assume we should get modulename_servicecode

Code: Select all

                        $serviceLevel = $rate['service_level']['name'];
                        $service_code = $rate['service_level']['code'];
                        $cost = $rate['rate']; // Total cost including VAT

                        $this->quotes['methods'][] = [
                            'id' => $this->code, 
                            'title' => $serviceLevel . ' (' . $service_code . ')',
                            'cost' => number_format($cost, 2, '.', ''),
                        ];

Re: Question on session shipping

Posted: Tue Mar 19, 2024 3:40 pm
by Pierre_P
Another question, i will try and describe.

In our shipping modules we do have generally have this code to show the method and cost:

Code: Select all

        $this->quotes = [
            'id' => $this->code,
            'module' => MODULE_SHIPPING_TABLE_TEXT_TITLE,
            'methods' => [[
                'id' => $this->code,
                'title' => MODULE_SHIPPING_TABLE_TEXT_WAY,
                'cost' => $shipping + (float)$this->calculate_handling(),
            ]],
        ];
What i could not see if you want to add more text to this output but not to append to the id or title.
Lets say we have a selection on page checkout_shipping.php as Table Rate and the cost, how to add text below Table Rate text for example "Delivered within 2 - 3 days"?

Re: Question on session shipping

Posted: Thu Mar 21, 2024 3:19 am
by ecartz
Pierre_P wrote: Tue Mar 19, 2024 3:40 pm What i could not see if you want to add more text to this output but not to append to the id or title.
There is no way to add text without adding it to the title except the icon. The icon would probably not work correctly for what you want. You'd have to modify the template if you wanted to do anything else without modifying the title.

Note: I'm assuming that you don't want to do Javascript jiggery/pokery in the injectFormDisplay or other hook. That would presumably work as well. Some of the certified developers might be able to help you with that.