Adding JavaScript to frontend of shipping method

  • Posts: 27
  • Thank you received: 4
9 years 3 months ago #209821

-- HikaShop version -- : 2.4.0
-- Joomla version -- : 3.4.1
-- PHP version -- : 5.3.10
-- Browser(s) name and version -- : Firefox 38.0.5

I am currently developing a shipping method plugin. I wanted to know if it's possible to add some sort of control to the frontend, either via JavaScript or PHP.

I basically want this flow:
1. User logs in and is on checkout step Address
2. Billing Address and Shipping Address are showing
3. When user selects the custom shipping method, the Shipping Address div becomes hidden
4. The custom shipping method allows the user to select the nearest pickup location. This location becomes the order's shipping address

I've looked through the developer's documentation, but haven't found any mentions on the things listed above.

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

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
9 years 3 months ago #209835

Hi,

What you describe can be done using just PHP (for the checks).
And for the shipping address ; the shipping structure have a feature which allow to override the shipping address.
Thanks to that, you can simply put an empty shipping address or put the address you want.

Using PHP will be quite better than the javascript ; because the address will be stored in the database.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.
The following user(s) said Thank You: fengel

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

  • Posts: 27
  • Thank you received: 4
9 years 3 months ago #209982

Thank you for the response. I actually found a thread that is applicable: here .

I have to agree with the OP of that thread that documentation on shipping plugins is a bit lacking.

I'm looking through the envoimoinscher plugin and it seems that it adds an additional checkout step called "Pick Up Points". Some questions about this:

  1. Should this step be on its own column, or can it exist in the same column as "Shipping"?
  2. Is it possible to combine the "Shipping" and "Pick Up Points" views into one? I wanted to have a cleaner UI by having the "Shipping" selection trigger an AJAX call, which then transitions to the "Pick Up Points" view on the same page.
  3. The displaying of the envoimoinscher_view is done by $this->showPage('view'), inside the onCheckoutStepDisplay function. Can $this->showPage also be used in the onShippingDisplay function?

Last edit: 9 years 3 months ago by fengel.

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
9 years 3 months ago #209983

Hi,

1. Both are possible.

2. It's possible too. You can edit the file "shipping" of the view "checkout" via the menu Display>Views if you want to add custom javascript on the selection of the shipping method in order to do the processing you want to display the pickup points view.

3. Yes, the $this->showPage() function will display its content in the current buffer. So if you call it in the onShippingDisplay function, you'll get it displayed at the top of the checkout.
That's probably something you don't want. You can start a new buffer before calling it and then retrieve the content of the buffer in order to add it to the display in the shipping view file or in the onCheckoutStepDisplay function (but then you could call it from there directly...)

The following user(s) said Thank You: fengel

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

Time to create page: 0.054 seconds
Powered by Kunena Forum