Question on session shipping

Open to all! Ask other shopowners for help.
Post Reply
User avatar
Pierre_P
Contributor
Posts: 144
Joined: Fri Mar 12, 2021 5:06 am
Phoenix Version: v1.1.0.6
Has thanked: 21 times
Been thanked: 11 times

Question on session shipping

Post 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.


Join The Code Co-op to get access to your library in the Code Co-op Forum
User avatar
burt
Core Team
Posts: 4551
Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
Has thanked: 252 times
Been thanked: 412 times

Re: Question on session shipping

Post 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".
I am not here to build for you.
I am here to build with you. Let's help each other.
raiwa
Certified Developer
Posts: 1640
Joined: Sat Dec 21, 2019 8:08 am
Phoenix Version: 1.1.0.6
Has thanked: 70 times
Been thanked: 152 times

Re: Question on session shipping

Post 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.
Public Phoenix Change Log Cheat Set on Google Sheets
https://docs.google.com/spreadsheets/d/ ... sp=sharing

Need Help?viewtopic.php?f=10&t=27
ecartz
Core Team
Posts: 3084
Joined: Tue Nov 05, 2019 6:02 pm
Phoenix Version:
Has thanked: 4 times
Been thanked: 208 times

Re: Question on session shipping

Post 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.
User avatar
Pierre_P
Contributor
Posts: 144
Joined: Fri Mar 12, 2021 5:06 am
Phoenix Version: v1.1.0.6
Has thanked: 21 times
Been thanked: 11 times

Re: Question on session shipping

Post 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, '.', ''),
                        ];
User avatar
Pierre_P
Contributor
Posts: 144
Joined: Fri Mar 12, 2021 5:06 am
Phoenix Version: v1.1.0.6
Has thanked: 21 times
Been thanked: 11 times

Re: Question on session shipping

Post 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"?
ecartz
Core Team
Posts: 3084
Joined: Tue Nov 05, 2019 6:02 pm
Phoenix Version:
Has thanked: 4 times
Been thanked: 208 times

Re: Question on session shipping

Post 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.


Join The Code Co-op to get access to your library in the Code Co-op Forum
Post Reply