checkout inconsistency

  • Posts: 26
  • Thank you received: 0
8 years 7 months ago #238285

-- HikaShop version -- : 2.6.2
-- Joomla version -- : 3.4.8

Hi.
I am customizing a 2-step checkout flow (login,address)(shipping,cart,payment)
I have come across the mentioned issue here www.hikashop.com/forum/checkout/874042-h...in-address-step.html (the need to submit the address in a different button than the "Next" button related to checkout steps)

I tried to encounter this issue by disabling "Require address on registration", now registration only asks for email , upon pressing next, the checkout displays both billing and shipping addresses,
here comes the problems, if you enter them and press next, you will stay on the same page and it displays the addresses with the option of adding new or removing the current addresses,
even worse, you can actually add the address by pressing the "Tick" button in the top of the address div , which will add and display the address with a "radiobutton" so you select the address , and check"shipping same as billing" , and press next, suddenly you stay in the same page with no changes in the page at all ! (because you already see the addresses added)
I think it's a bug in the checkout flow, please I appreciate any help in fixing this bug

Last edit: 8 years 7 months ago by issa.mouawad.

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

  • Posts: 82906
  • Thank you received: 13378
  • MODERATOR
8 years 7 months ago #238333

Hi,

Change the code:

if($shipping!=$oldShippingAddress){

			$cart = $this->initCart();
			if($cart->has_shipping){

				$this->cart_update=true;
				if(strpos($this->checkout_workflow,'shipping')!==false){
					$this->before_shipping(true);
				}
				if(strpos($this->checkout_workflow,'payment')!==false){
					$this->before_payment(true);
				}
				return false;
			}
		}
		if($billing!=$oldBillingAddress){
			return false;
		}
to:
if($shipping!=$oldShippingAddress){

			$cart = $this->initCart();
			if($cart->has_shipping){

				$this->cart_update=true;
				if(strpos($this->checkout_workflow,'shipping')!==false){
					$this->before_shipping(true);
				}
				if(strpos($this->checkout_workflow,'payment')!==false){
					$this->before_payment(true);
				}
				return true;
			}
		}
		if($billing!=$oldBillingAddress){
			return true;
		}
in the file components/com_hikashop/controllers/checkout.php and it will go to the next step when you click on the next button.

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

  • Posts: 26
  • Thank you received: 0
8 years 6 months ago #239859

Hi , I am actually struggling with the same issue,
I need to simplify the flow and enable the next step only if "Next" is clicked
that is, I want the "after address" method in the checkout controller to return true only if "next" was clicked (not by selecting the radio button or anything)
I thought I could add a hidden field and set that field's value in the "next" click handler, and then check in the "after address" if this field has a certain value,
I have the scenario in my head but I need a little help on the implementation(like which view to add the hidden field in, how to inject the javascript in the 'next' click)

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

  • Posts: 82906
  • Thank you received: 13378
  • MODERATOR
8 years 6 months ago #239863

Hi,

If you want to add your check in the after address, you want to add the hidden input in the file "address" of the view "checkout".
The next button is displayed in the file "step" of the view "checkout". I suppose that you'll want to add your custom JS before:

document.forms[\'hikashop_checkout_form\'].submit();

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

  • Posts: 26
  • Thank you received: 0
8 years 6 months ago #239906

Thanks ! it all works now ..
I actually need another help too,
I want to initially display shipping address form if the user is guest and nb_addresses =1 , (I want the default interaction, that the guest user adds a shipping address different than the billing address , unless of course he wants to tick the "same address" check)
I figured out how to do the checks (check if user is guest and nb_addresses=1)
but I don't know how to convert the shipping address area to "add" mode , I tried in view "address/select" maybe I it's another view I should place the logic in ?

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

  • Posts: 82906
  • Thank you received: 13378
  • MODERATOR
8 years 6 months ago #239909

Hi,

Changing the address area can be done like in the address/show view file which such javascript:

window.addressMgr.update<?php echo ucfirst($this->type);?> = function() {
	window.Oby.xRequest('<?php echo hikashop_completeLink('address&task=show&subtask='.$this->type.'_address&cid='.$this->address_id, true, false, true); ?>',{update:'<?php echo $this->fieldset_id; ?>'});
};
So it's just a call to xRequest with the link for the edit/show subtask, the id of the address and the update parameter with the id of the HTML element to be updated.

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

  • Posts: 26
  • Thank you received: 0
8 years 6 months ago #240018

when should I add this ?
I have added the code you provided in window.onload but nothing changed
to clarify, I don't want the address to be edited , but rather to add a new one , so I thought I should use
return window.localPage.switchAddr(0, 'shipping');
any help on how to accomplish that?

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

  • Posts: 82906
  • Thank you received: 13378
  • MODERATOR
8 years 6 months ago #240019

Mmm. I'm not sure what you mean by add a new one.
The window.addressMgr.updateShipping and window.addressMgr.updateBilling javascript functions are to refresh the billing/shipping area.
The window.localPage.switchAddr function is to change the selected shipping/billing address.
Adding a new address requires using the window.hikashop.form(this,'<?php echo $this->fieldset_id; ?>'); function call like it's done in the onclick of the save button in address/show with the hidden input field with the name data[address_id] having a value of 0 instead of an address_id.

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

Time to create page: 0.050 seconds
Powered by Kunena Forum