Step 1 in checkout is repeated

  • Posts: 45
  • Thank you received: 0
9 years 5 months ago #204562

-- HikaShop version -- : 2.3.5
-- Joomla version -- : 3.4
-- PHP version -- : 5.5
-- Browser(s) name and version -- : Chrome

Hi,

I've made my own payment plugin that selects a payment method and issuer in the payment selection pane. When I accept my choices and press the 'finish' button, the same page reappears. Pressing 'finish' once more takes me to the redirect to payment service provider page.
While debugging this issue I found in checkout.php the following snippet that plays an important role here (lines 1187 and further)

			$app = JFactory::getApplication();
			$old_payment_method = $app->getUserState(HIKASHOP_COMPONENT.'.payment_method');
			$old_payment_data = $app->getUserState(HIKASHOP_COMPONENT.'.payment_data');
			$old_payment_id = $app->getUserState(HIKASHOP_COMPONENT.'.payment_id');
			$app->setUserState( HIKASHOP_COMPONENT.'.payment_method',$payment);
			$app->setUserState( HIKASHOP_COMPONENT.'.payment_id',$payment_id);
			$price_all = @$cart->full_total->prices[0]->price_value_with_tax;
			if(isset($cart->full_total->prices[0]->price_value_without_payment_with_tax)){
				$price_all = @$cart->full_total->prices[0]->price_value_without_payment_with_tax;
			}
			$currencyClass = hikashop_get('class.currency');
			$currencyClass->convertPayments($rates);
			$paymentData->payment_price = ($price_all * (float)@$paymentData->payment_params->payment_percentage / 100) + $paymentData->payment_price;
			$app->setUserState( HIKASHOP_COMPONENT.'.payment_data',$paymentData);

			if(!empty($paymentData->ask_cc)){
				$paymentClass = hikashop_get('class.payment');
				if(!$paymentClass->readCC()){
					return false;
				}
			}

			if(($old_payment_id!=$payment_id || $old_payment_method!=$payment) || @$old_payment_data->payment_price!=$paymentData->payment_price && ($this->_getStep('cart',(int)$this->previous)===(int)$this->previous || $this->_getStep('confirm',(int)$this->previous)===(int)$this->previous)){
				return false;
			}
My workaround is to preload the $app->getUserState(HIKASHOP_COMPONENT.'.payment_method'); and $app->getUserState(HIKASHOP_COMPONENT.'.payment_id'); in the plugin's onPaymentSave() method in the following manner:
		$app = JFactory::getApplication();
		$app->setUserState( HIKASHOP_COMPONENT.'.payment_id',$payment_id);
		$app->setUserState( HIKASHOP_COMPONENT.'.payment_method','mypayment');

This workaround seems to be OK, but I'm wondering what the purpose of the check in checkout is and whether such a workaround is needed.

Your thoughts are appreciated, as always.

Best regards, Paul

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

  • Posts: 12953
  • Thank you received: 1778
9 years 5 months ago #204578

Hello Paul,
Firstly can you show me how did you configured the page "Hikahsop->System->Configuration->Checkout" through some screenshots ?
Thanks.

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

  • Posts: 45
  • Thank you received: 0
9 years 5 months ago #204581

Hi Mohamed,

Please find attached.

Thanks, Paul.

Attachments:

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

  • Posts: 82866
  • Thank you received: 13373
  • MODERATOR
9 years 5 months ago #204585

Hi,

You turned off the "auto select shipping and payment methods" and the "auto submit payment and shipping methods selection" settings there.
That's probably why you get that behavior and your code just does what these option do.

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

Time to create page: 0.071 seconds
Powered by Kunena Forum