google checkout is not applying any coupon codes

  • Posts: 24
  • Thank you received: 0
12 years 8 months ago #42484

The discounted amount shows on my checkout page and in my sales history, but the customers order on google checkout is not receiving the discount information so it charges them the full price, www.germfreetoothbrush.com you need to order 3 or more to see

I attached the two screen prints.

I am not sure if it is applicable but I changed the original code so each item would show in google checkout

I also attached a copy of my google php

Attachments:

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

  • Posts: 24
  • Thank you received: 0
12 years 8 months ago #42485

<?php

	function onAfterOrderConfirm(&$order,&$methods,$method_id) {
		$method =& $methods[$method_id];
		$currencyClass = hikashop::get('class.currency');
		$currencies = null;
		$currencies = $currencyClass->getCurrencies($order->order_currency_id,$currencies);
		$currency = $currencies[$order->order_currency_id];
		hikashop::loadUser(true,true); //reset user data in case the emails were changed in the email code
		$user = hikashop::loadUser(true);
		$lang = &JFactory::getLanguage();
		$locale = strtolower(substr($lang->get('tag'),0,2));
		$httpsHikashop = str_replace('http://','https://', HIKASHOP_LIVE);
		$notify_url = $httpsHikashop.'index.php?option=com_hikashop&ctrl=checkout&task=notify&notif_payment=googlecheckout&tmpl=component&lang='.$locale;
		$return_url = $httpsHikashop.'index.php?option=com_hikashop&ctrl=checkout&task=notify&notif_payment=googlecheckout&tmpl=component&user_return=1&lang='.$locale;
		$app =& JFactory::getApplication();
		$address = $app->getUserState( HIKASHOP_COMPONENT.'.billing_address');
		$price = round($order->cart->full_total->prices[0]->price_value_with_tax,(int)$currency->currency_locale['int_frac_digits']);
		$data = '<'.'?xml version="1.0" encoding="UTF-8"?'.'>'."\n";
$data .= '<checkout-shopping-cart xmlns="checkout.google.com/schema/2"><shopping-cart><items>';

foreach($order->cart->products as $product){

$data .= '<item><item-name>Order #'.$order->order_id.' - '.$product->order_product_name.'</item-name><item-description></item-description><unit-price currency="'.$currency->currency_code.'">'.$product->order_product_price.'</unit-price><quantity>'.$product->order_product_quantity.'</quantity></item>';

}
$data .= '<item><item-name>Order #'.$order->order_id.' - Shipping</item-name><item-description></item-description>
<unit-price currency="'.$currency->currency_code.'">'.$order->order_shipping_price.'</unit-price><quantity>1</quantity></item>';
$data .= '</items></shopping-cart><checkout-flow-support><merchant-checkout-flow-support/></checkout-flow-support></checkout-shopping-cart>';
		if( $method->payment_params->debug ) { echo 'XML Sent to Google<pre>'.htmlentities($data).'</pre>'; }
		if( $method->payment_params->server_to_server == true ) {
			$ret =& $this->webCall('checkout', $data, $method->payment_params);
			if( $ret !== false ) {
				if( preg_match('#<redirect-url>(.*)</redirect-url>#iU', $ret, $redirect) ) {
					$redirect = html_entity_decode(trim($redirect[1]));
					$app =& JFactory::getApplication();
					$app->redirect($redirect);
				}
				if( $method->payment_params->debug ) { echo 'Google call return<pre>'.htmlentities($ret).'</pre>'; }
			} 
			$url = '';
			$vars = '';
			$app =& JFactory::getApplication();
			$app->enqueueMessage('Google Checkout error. Please log-in to the backend of Google Checkout to see the log.');
		} else {
			$vars = array(
				'signature' => base64_encode($this->signature($data, $method->payment_params->merchant_key)),
				'cart' => base64_encode($data)
			);
			if( $method->payment_params->sandbox ) {
				$url = 'https://sandbox.google.com/checkout/api/checkout/v2/checkout/Merchant/';
			} else {
				$url = 'https://checkout.google.com/api/checkout/v2/checkout/Merchant/';
			}
			$url .= $method->payment_params->merchant_id;
		}
		JHTML::_('behavior.mootools');
		$app =& JFactory::getApplication();
		$name = $method->payment_type.'_end.php';
		$path = JPATH_THEMES.DS.$app->getTemplate().DS.'hikashoppayment'.DS.$name;
		if(!file_exists($path)){
			if(version_compare(JVERSION,'1.6','<')){
				$path = JPATH_PLUGINS .DS.'hikashoppayment'.DS.$name;
			}else{
				$path = JPATH_PLUGINS .DS.'hikashoppayment'.DS.$method->payment_type.DS.$name;
			}
			if(!file_exists($path)){
				return true;
			}
		}
		require($path);
		return true;
	}

Last edit: 12 years 8 months ago by nicolas. Reason: adding code tags

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

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
12 years 8 months ago #42652

I can see that you changed the code of that plugin so that it displays each product in the cart on google checkout instead of just the total price.
You forgot to handle the coupon price so of google checkout won't take it into account.

If you revert to the default google checkout plugin code, you won't have that problem.

Otherwise, you can add such code after the shipping handling code in order to handle the coupon:

$data .= '<item><item-name>Order #'.$order->order_id.' - Coupon</item-name><item-description></item-description>
<unit-price currency="'.$currency->currency_code.'">-'.$order->order_discount_price.'</unit-price><quantity>1</quantity></item>';

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

  • Posts: 24
  • Thank you received: 0
12 years 8 months ago #42709

works like a champ, thanks for the help and quick response

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

Time to create page: 0.068 seconds
Powered by Kunena Forum