Checkout shipping view display

  • Posts: 1119
  • Thank you received: 114
5 years 1 month ago #312252

Hi,

Is there a way to find if user has address or not in show_block_shipping.php?

What i am looking for is to hide shipping options until address is entered, same applies for payment methods....

Any guide would be appreciated?

Thank you

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

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
5 years 1 month ago #312261

Sure.

Near the beginning of both view files, you can see the line:
$cart = $this->checkoutHelper->getCart();
This loads the full cart of the customer.
In $cart->billing_address and $cart->shipping_address you'll find the selected billing and shipping addresses.
So you could have a check like this:
if(empty($cart->billing_address)) {
// my code
}

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

  • Posts: 1119
  • Thank you received: 114
5 years 1 month ago #312269

Hi,

1. Thanks Nicolas, That's indeed a solution. However it works partially. It seems i need to refresh shipping block after address submit/refresh. lse after address is submited i need to refresh page in order to see changes... Something has changed with newer Hikashop version compared with Hikashop 3.5.1 and shipping/payment blocks wont update it self if not needed... I tried to add "checkout.shipping.updated" into:

window.Oby.registerAjax(['checkout.user.updated','checkout.address.updated'], function(params){
	window.checkout.refreshAddress(<?php echo (int)$this->step; ?>, <?php echo (int)$this->module_position; ?>);
});

But that didn't work. What would be the correct way of doing it?

2. Maybe as a feature request it would be great if we could limit custom field table address to shipping/payment methods. With some shipping methods you don't need to have full user address, as example pick up points, where you only need name, phone, email and pick up point location... Unless where is another way of doing it?

As usual, thanks for you great support.

Regards

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

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
5 years 1 month ago #312270

Hi,

1. Indeed, the shipping/payment views are not refreshed if not needed.
The change that was made is the addition of this code in the show_block_payment and show_block_shipping view files:

if(window.checkout.isSource(params, <?php echo (int)$this->step; ?>, <?php echo (int)$this->module_position; ?>))
		return;
However, if you need to refresh the shipping/payment views when the address changes, then what you want to do is to change the line:
window.Oby.registerAjax(, function(params){
in the show_block_payment view file to include checkout.address.updated (and same for shipping).

2. You could have the phone as a custom order field and activate the "shipping address override" setting of the shipping method which doesn't need the shipping address.

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
5 years 1 month ago #312286

3. One more question:

var_dump($this->options['display']);

This returns true or false in show_block_address.php based on guest information is submited or not.

However it return NULL in show_block_shipping.php. Is there a way to have same behiviour as in address block?

Thanks

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

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
5 years 1 month ago #312290

Hi,

That parameter is set based on this line:

$params['display'] = $checkoutHelper->isLoggedUser() && ($params['show_billing'] || $params['show_shipping']);
in administrator/components/com_hikashop/helpers/checkout/address.php
This means that this variable will be true if the user is logged in (or has filled in the guest information) and the address block has to display either the shipping or the billing address areas.
So at the beginning of show_block_shipping, you could have something like that I guess:
$checkoutHelper = hikashopCheckoutHelper::get();
$this->options['display'] = $checkoutHelper->isLoggedUser();

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
5 years 1 month ago #312301

Hi,

Thanks. That worked!

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

  • Posts: 1119
  • Thank you received: 114
5 years 1 month ago #312315

Hi,

Probably the last question.

In show_block_address.php i have removed:

if(!empty($this->options['display'])) {

but that didn't make a lot difference. It seems that:
$this->cart_addresses['data']

is empty while you are in guest information/email edition mode.

Is there a way not to hide address while editing guest information?


I also tried like this, which works in other checkout views but not in address, not sure why:
$this->cart_addresses = $this->checkoutHelper->getAddresses();
foreach($this->cart_addresses['data'] as $address) {
}

The idea is, insteed of hiding whole address block, i would like to add some kinda overlay while in guest information/email edition mode.

Thanks

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

  • Posts: 1119
  • Thank you received: 114
5 years 1 month ago #312319

And another thing i noticed.

Each time guest user modifies hes email the new customer is created with new email. Wouldn't be better to update it as existing one insteed of creating new customer? Especially if the address has been filled and after changing email, you need to enter address again...

Thanks again

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

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
5 years 1 month ago #312320

Hi,

$this->cart_addresses['data']
contains the addresses of the user. If the user hasn't yet filled in his guest form or has logged in, there is no user entry in HikaShop for him and thus no addresses attached to that user entry.
And that's the same with:
$this->cart_addresses = $this->checkoutHelper->getAddresses();
So you can't ask the address view to display a selector of addresses as there are no addresses to use.
So I don't see what you mean by "some kinda overlay while in guest information/email edition mode".
what is an overlay for you ? And by "guest information/email edition mode" I suppose that you mean "before the user has filled anything", is that correct ?

Last edit: 5 years 1 month ago by nicolas.

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

  • Posts: 1119
  • Thank you received: 114
5 years 1 month ago #312350

Hi,

Sorry if i was not clear enought. Let me explain.

As example i have checkout only as a guest and configured as per my screenshot attached.

When user first come to checkout he see only email input to enter, then shipping and payment methods. The address is not visible. So all is fine.

When user adds email and press submit button, the blocks are refreshed and new shipping address is asked to add. So he fills it and submits...All fine here.

After user submits address, we see guest user information, address, shipping and payment blocks. All great here too...

Now what i don't like:

1. If user press change guest information, the address is hidden ( here i would like address still be visible but with some overlay which would have css like opacity:0.5, pointers-events:none ), which basically would prevent him to edit address while changing guest information.

2. If user change hes email (maybe because of mistake), he needs to fill address again. But he only want to edit email and nothing else, so why would he need extra effort to add same address again?

3. Each time user changes hes email, the new custom is created in back-end? Wouldn't it be better to update it as the existing one. It's the same person is changing hes email, which he added like 2-4 minutes ago.... + less useless customers in back-end.

4. After checkout, if user wants to buy something again, the guest information (email) is there (which is great), but the address is empty and he must add it again?

I have investigated like 20 checkouts of high brands and this is not like for my needs, this is more for better user experience and make Hikashop even more better!

I hope you see what i mean and what i want to do/have.

Thank you

Attachments:

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

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
5 years 1 month ago #312354

Hi,

I think the main issue here is that you're in a case I didn't test when adding the possibility to edit your guest information.
I always tried with the "ask address on registration" option activated.
And in that case, the address you had as the selected billing address is preset in the guest form and thus when you resubmit it, you still have the address.
This basically prevented me from seeing the two first points of your message.

So we could indeed make something to improve the workflow when the "ask address on registration" option is deactivated.

3. This could be improved. But the gain is minimal for development work not that easy. I would prefer to spend time on more useful things.

4. Yes. That's for security reasons. Otherwise, anyone knowing the email address of someone who guest checkout on your website would be able to retrieve his address and that's an issue for privacy laws. It could be done, but then it would need the addition of some sort of token attached to the user, like we did with orders for guest checkouts so that people can still access their order information later on. So it's again not that easy.

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

  • Posts: 1119
  • Thank you received: 114
5 years 1 month ago #312374

Hi,

1. and 2. Please consider to improve it. Maybe it is not a big deal but again it is easier for a customer. Less time he spend on checkout less possibility that he will abandon it...

3. If work is not easy then you totally right that it is better to spend time for more useful things.

4. Agree.

Thanks again for support.

Have a great day

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

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
5 years 1 month ago #312379

Yes, thank you for your feedback. I've noted your points on my end.

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

  • Posts: 1119
  • Thank you received: 114
5 years 1 month ago #312446

Hi,

What would be right way to refresh login block after shipping selected?

As address gets empty after changing email of guest user, i had to set "ask address on registration" to YES. Now i want to display different address fields based on shipping method selected, so i need to refresh them each time shipping method has changed?

Please advise.

Thank you

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

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
5 years 1 month ago #312447

Hi,

In the "show_block_shipping" view file, in the window.checkout.shippingSelected function definition, after the call of the processEvents function ( window.checkout.processEvents(r.events, {step:<?php echo (int)$this->step; ?>, pos:<?php echo (int)$this->module_position; ?>}); ), you can add the call to the window.checkout.refreshLogin(); function which will refresh the login view.

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

Time to create page: 0.088 seconds
Powered by Kunena Forum