Shipping method with dropdown selection?

  • Posts: 1119
  • Thank you received: 114
8 years 5 months ago #242178

Hi,

I have looked to shipping plugins and couldn't find anything what I need.
In our country we have very popular shipping method via terminals...and a lot buyers are asking for it. So I need shipping method where should be dropdown list with addresses/terminals selection. I should see this selection in back-end after order created as well.
How can I achieve this?

Thanks

Last edit: 8 years 5 months ago by kyratn.

Please Log in or Create an account to join the conversation.

  • Posts: 12953
  • Thank you received: 1778
8 years 5 months ago #242216

Hello,

Can you give us more information about what you exactly want to do through some screenshots for example so that we can properly understand it and help you ?

Thank you.

Last edit: 8 years 5 months ago by Mohamed Thelji.

Please Log in or Create an account to join the conversation.

  • Posts: 1119
  • Thank you received: 114
8 years 5 months ago #242246

Hi,

I have added some screenshots to be more clear. Basically it is same as per this thread, but I need only single selection. I also think this should be added to hikashop shipping plugin itself.
I could take one of hikashop shipping plugins and customize it to my needs but problem is that I don't know how to add it that these options/terminal addresses could be added in plugin so buyer could choose and after order, it should be shown in back-end order view so I would know which terminal buyer has chosen. Is there a easy way to do it?

www.hikashop.com/forum/shipping-methods/...st/reply/242202.html

Thanks

Attachments:
Last edit: 8 years 5 months ago by kyratn.

Please Log in or Create an account to join the conversation.

  • Posts: 12953
  • Thank you received: 1778
8 years 5 months ago #242258

Hello,

I also think this should be added to hikashop shipping plugin itself.

We can potentially add it on our TODO list, but in your case the best solution will be to directly edit the code of one of our shipping plugin and develop it so that it properly suit your needs.

Please Log in or Create an account to join the conversation.

  • Posts: 1119
  • Thank you received: 114
8 years 5 months ago #242703

Hi,

Sorry for late replay.
What I am looking to is this:

Inside plugin to have some inputs where I could write addresses or it can be checkboxes as most shipping plugins have... Then these should be displayed on checkout in that shipping method. Dropdown or whatever.... After selection and placed order it should be visible in back-end order view. I think this is simple task for someone with better php knowledge then me.

So if it is possible could you please give me some simple example how can I have input label to be displayed in shipping method?

Or another solution to show table->order custom fields in shipping method?

Thanks

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
8 years 5 months ago #242714

Hi,

The simplest is to use custom order fields. Then, just edit the file "custom_fields" of the view "checkout" and add a bit of custom code to hide/display the custom fields based on the shipping method selected.
For example, something like that at the beginning :
$app = JFactory::getApplication();
$shipping_id = reset($app->getUserState(HIKASHOP_COMPONENT.'.shipping_id'));
if($shipping_id == 'XXX@0') continue;

where XXX is the id of the shipping method for which you don't want the custom order fields to display on the checkout.

Note that this requires the custom fields to not be required.

The following user(s) said Thank You: kyratn

Please Log in or Create an account to join the conversation.

  • Posts: 1119
  • Thank you received: 114
8 years 5 months ago #242741

Hi,

1. Thats sounds like a good idea but what if i have 2 shipping methods with terminals? What if i wish to use custom fields for another thing in checkout? Example: Notes.
So there is no way to display it on shipping method itself?

2. Also i am looking for someone to create one of these kind plugins for me but i affraid that this require some modifications on checkout itself and after hikashop 3 release i will have to do it again...

3. I have looked into ups, fedex, usps shipping plugins and they have shipping option selection in configuration (checkboxes) I wanted to see how it looks on front-end but none of these shipping methods showed up on my checkout. Is this because I had no Api, username entered in configuration......?

Update. So it seems i wil stick with custom field. I have created some and found what i need. However i still have some questions.

4. Your code provided will display custom field if xxx shipping method selected. How can i have that custom field show if xxx shipping method selected and other custom field (Note) to be shown else there always?

5.How can i display selected terminal/custom field value title in checkout status field near selected shipping method.

Now we have this.

Your shipping method is: Omniva terminal

But i need to have this.

Your shipping method is: Omniva terminal >selected value title here<

Same applys to order creation notification email and Front-end order details page.

6. Your code provided seems not working (some fatal errors...), i have changed continue to return false and it started to work, not sure is it right...
How can i have custom field to be shown only with one of shipping methods selected? I have 7 shipping methods.... I tried to modify yours but it didnt work for me.

Thanks

Last edit: 8 years 5 months ago by kyratn.

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
8 years 5 months ago #242773

Hi,

1. It's just a basic example I gave. More complex modifications, with ifs can allow you to do these too.
There is no system in place to display fields inside the shipping methods selection system like there is for payment methods.
The system wasn't made for that in the first place. That's why I proposed to use custom order fields with simple hide/display code based on the shipping method selected. It's much more simple than to adapt the core of HikaShop to handle shipping methods fields.

2. HikaShop 3 will have a backward compatible checkout, so you'll be able to use the old checkout system. But yes, if you'll want to use the new checkout system, modifications will be necessary to your code customizations to work with it.

3. Yes, since they contact UPS/Fedex, etc to calculate dynamically the rates, you need to provide the API credentials for the plugins to be able to contact the server.

4. and 6. Then, after the line:

foreach($this->extraFields[$type] as $fieldName => $oneExtraField) {
you could have such code:
$app = JFactory::getApplication();
$shipping_id = reset($app->getUserState(HIKASHOP_COMPONENT.'.shipping_id'));
if($fieldName=='AAA' && $shipping_id == 'XXX@0') continue;
if($fieldName=='BBB' && $shipping_id == 'YYY@0') continue;
That way, it will skip the display of the field with the column name AAA if the shipping method selected is the one with the id XXX, and it will skip the display of the field with the column name BBB if the shipping method selected is the one with the id YYY.
And the field with the column name CCC will always display.

5. You'll want to edit the file "status" of the view "checkout" and add such code:
$app = JFactory::getApplication();
$order = $app->getUserState( HIKASHOP_COMPONENT.'.checkout_fields',null);
echo $order->XXX;

Please Log in or Create an account to join the conversation.

  • Posts: 1119
  • Thank you received: 114
8 years 5 months ago #242903

Hi,

Thanks for help Nicolas.
It seems everything can be done with custom fields. All works find but just need some css for better look...
However I still do have one problem.

I have created one manual shipping method for terminals shipping.
In our country we have 2 shipping terminals providers. So I would like to use them both.
I am configuring custom fields like this.:

Created custom field with field type radio buttons, named it Terminal, with two values. First name Omniva, second name Lpexpress.
Then created custom field with field type single dropdown and named it Omniva and assigned it to custom field Terminal to value Omniva
Then created custom field with field type single dropdown and named it Lpexpress and assigned it to custom field Terminal to value Lpexpress.

So I would like that then people select terminal shipping they could choose to deliver parcel to Omniva or Lpexpress terminals.
Basically I have created switcher with single dropdown selection....

Now the problem is that this code provided will display field value.

$app = JFactory::getApplication();
$order = $app->getUserState( HIKASHOP_COMPONENT.'.checkout_fields',null);
echo $order->XXX;

And I will have to echo two custom field names. echo $order->Omniva; echo $order->Lpexpress;
As I don't know which courier buyer will select.

I have attached some screenshot how it looks.

And it will display like this:

Your shipping method is: Omniva terminal >selected Omniva value title here<>default value of Lpexpress<

How can I just display selected value based on custom field radio button selection and get rid of that default second value which is not selected by the buyer...

I know I could just create two shipping methods and it will be much easier to configure but maybe there is a way to have what I want.

Kind Regards

Attachments:
Last edit: 8 years 5 months ago by kyratn.

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
8 years 5 months ago #242923

Hi,

You just need to adapt your code.
For example:

if($order->XXX=='YYY')
 echo $order->AAA;
else
 echo $order->BBB;
where XXX is the column name of the first custom field, YYY the value for the first selection of that custom field, AAA the column name of the second custom field displaying when YYY is selected in XXX, and BBB the column name of the third custom field, displaying with ZZZ is selected in XXX.

The following user(s) said Thank You: kyratn

Please Log in or Create an account to join the conversation.

  • Posts: 1119
  • Thank you received: 114
8 years 5 months ago #242970

Thank you very much for help.

Please Log in or Create an account to join the conversation.

  • Posts: 1119
  • Thank you received: 114
8 years 5 months ago #243025

Can I have help once more please?

I have configured everything and it seems to work but If any other shipping method is selected it will show default value of YYY near shipping method name. How can I hide it? I have tried to use if condition depending on shipping method id but it didn't work.
I could add space or something but I have used default value as a notice: Warning no terminal selected! and it will display if nothing has been chosen by the buyer...

This is the code I have in my status view:

<?php
/**
 * @package	HikaShop for Joomla!
 * @version	2.3.2
 * @author	hikashop.com
 * @copyright	(C) 2010-2014 HIKARI SOFTWARE. All rights reserved.
 * @license	GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */
defined('_JEXEC') or die('Restricted access');
?><br/>
<span id="hikashop_checkout_status">
<?php
$app = JFactory::getApplication();
    $order = $app->getUserState( HIKASHOP_COMPONENT.'.checkout_fields',null);
	   if($order->ikuriterminalapristatyti=='1'){
       $text1 = $order->lpexpress;
	  }else{
       $text2 = $order->test;
	  }
	$array = array();
	if(!empty($this->shipping_data)) {
        $names = array();
        foreach ($this->shipping_data as $shipping) {
            $names[] = $shipping->shipping_name;
        }
        $array[] = JText::sprintf('HIKASHOP_SHIPPING_METHOD_CHOSEN', '<span class="label label-info">' . implode(', ', $names).' '.$text1.$text2.'</span>');
    }
	if(!empty($this->payment_data)) {
		$array[]= JText::sprintf('HIKASHOP_PAYMENT_METHOD_CHOSEN', '<span class="label label-info">'.$this->payment_data->payment_name.'</span>');
	}
	echo implode('<br/> <br/>', $array);
?>
</span>
<div class="clear_both"></div>

Last edit: 8 years 5 months ago by kyratn.

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
8 years 5 months ago #243027

Hi,

I don't know how you configured your custom fields so hard to say exactly.
But I guess you could try this:

if($text1 == '0') $text1 = '';
if($text2 == '0') $text2 = '';
Before the line:
$array[] = JText::sprintf('HIKASHOP_SHIPPING_METHOD_CHOSEN', '<span class="label label-info">' . implode(', ', $names).' '.$text1.$text2.'</span>');

The following user(s) said Thank You: kyratn

Please Log in or Create an account to join the conversation.

  • Posts: 1119
  • Thank you received: 114
8 years 5 months ago #243082

Hi,

1. Thanks for help!

Ended up with this:

if($shipping->shipping_name == 'Pristatyti i terminala' && $text1 == '0') {
			$text1 = ' Demesio klaida!';
		}elseif ($text1 == '0') $text1 = '';
        if($text2 == '0') $text2 = ' Demesio klaida!';

However i couldnt understand why it does work with shipping_name but not with shipping_id

The code i had with shipping_id is as below:
$shipping_id = $app->getUserState( HIKASHOP_COMPONENT.'.shipping_id');
if($shipping_id == '8@0' && $text1 == '0') {
			$text1 = ' Demesio klaida!';
		}elseif ($text1 == '0') $text1 = '';
        if($text2 == '0') $text2 = ' Demesio klaida!';
It;s just it didnt want to use shipping_id...
I even tried to do var dumb and clearly could see shipping_id

May i know what is the difference?

2. Update:

It seems I need another coding help with it.

I would like to split address in two fields as some of them are long enough.

Example of address:

Vilnius, Long way 7 (Central post), Lt-04208, Terminal is near the building somewhere in the forest...

So in custom field I would like to enter like this:

Value: Terminal is near the building somewhere in the forest...
Title: Vilnius, Long way 7 (Central post), Lt-04208

In single dropdown selection we see title as selection. So is there a way to echo value in field view or custom_field view based on that custom field title selection? Attached image to be more clear.

I have seen this feature on some prestashop sites and would like to add it too.


Thanks

Attachments:
Last edit: 8 years 5 months ago by kyratn.

Please Log in or Create an account to join the conversation.

  • Posts: 12953
  • Thank you received: 1778
8 years 5 months ago #243091

Hello,

I even tried to do var dumb and clearly could see shipping_id

The shipping_id is structured by :
- the shipping ID 8
- the warehouse ID 0 if you don't have any warehouse

and both these informations are separated by an "@".

Can you show us what was displayed when you tried to do a var_dump ?

Thank you.

Please Log in or Create an account to join the conversation.

  • Posts: 1119
  • Thank you received: 114
8 years 5 months ago #243133

Hi,

This is what I had when used shipping method with id=8 and used that code in status view:

var_dump($shipping_id);

array(1) { [0]=> string(3) "8@0" }

You can see shipping_id is fine so it had to work with shipping_id, isn't it?
But as I said it has been resolved as I used name instead of id...

I would like to have help with my second question please.

Thank you

Last edit: 8 years 5 months ago by kyratn.

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
8 years 5 months ago #243150

Hi,

I think that you need to create new custom fields of the type "custom text" with their "display limited to" setting configured to only display for one of the choice of the Lpexpress field. That way, the system will switch from one custom text to another without even one line of code.

Please Log in or Create an account to join the conversation.

  • Posts: 1119
  • Thank you received: 114
8 years 5 months ago #243219

Hi,

1.I was thinking about it too but I will have to create about 60 custom fields and limit everyone to one of these values/titles. Am I correct?
Wont it be to much custom fields for it :)

2. is there a way to see hikashop 3 preview somewhere or what changes it will have? Any release date?

Thanks

Last edit: 8 years 5 months ago by kyratn.

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
8 years 5 months ago #243269

Hi,

1. No. The system can handle tens of thousands of custom fields. 60 will be a piece of cake for it.
You can always use custom coding instead with custom javascript code... But you're on your own then. We've given you enough code examples on that topic...

2. I've done a preview on the first HikaShop Day ever last weekend in the Netherlands. There is no other preview available for now.
We don't have a release date yet. We hope that it will be by the end of the summer.

Please Log in or Create an account to join the conversation.

  • Posts: 1119
  • Thank you received: 114
8 years 5 months ago #243318

nicolas wrote: We've given you enough code examples on that topic...


True! And i am very thankful for it.

Have a great day

Last edit: 8 years 5 months ago by kyratn.

Please Log in or Create an account to join the conversation.

Time to create page: 0.115 seconds
Powered by Kunena Forum