TIP LINE

  • Posts: 1
  • Thank you received: 0
11 years 1 month ago #153596

-- url of the page with the problem -- : www.wingkingenglewood.com
-- HikaShop version -- : 2.3.0
-- Joomla version -- : 3.2.3
-- PHP version -- :5.3.28
-- Browser(s) name and version -- : explorer 11
-- Error-message(debug-mod must be tuned on) -- : No error message
Is it possible to add a TIP LINE in the CHECKOUT?

Thank you for any help.
John

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

  • Posts: 83933
  • Thank you received: 13588
  • MODERATOR
11 years 1 month ago #153614

Hi,

There is no option for that.
That would require custom coding. You would have to create a custom order field via the menu Display>Custom fields so that the user could enter the tip and then you would have to create a small HikaShop plugin implementing the trigger onAfterCartShippingLoad and add the value of the custom field in the array $cart->additional.

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

  • Posts: 9
  • Thank you received: 1
11 years 1 week ago #158165

I am the webmaster of wingkingenglewood.com. I tried to implement the tip line like suggested and it almost works... Only problem is that $cart does not keep the additional info in the next steps. I have the tip line a couple steps before the Summary page. If I print_r $cart on the summary page for instance, the info I added to $cart->additional disappeared.
Any ideas? Thank you!
Here is my plugin code:

class plgHikashopTwt_tip extends JPlugin {
	function plgHikashopTwt_tip(&$subject, $config){
		parent::__construct($subject, $config);
	}


	function onAfterCartProductsLoad(&$cart) {
		$array = $_POST['data'];
		if(array_key_exists('tip',$array['order'])) {
			if(preg_match('/^\d+(?:\.\d{2})?$/',$array['order']['tip'])) {
				 $price = $array['order']['tip'];
			} else {
				$price = "0.00";
			}
			$object->price_value = (string)$price;
			$object->price_value_with_tax = (string)$price;
			$object->price_currency_id=2;
			$object->name="TIP";
			$object->value=0;
			$cart->additional['tip']=$object;
		}
	}
}

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

  • Posts: 9
  • Thank you received: 1
11 years 1 week ago #158212

I used now Joomla Sessions to readd it on every page to the cart object. Seems to work now...

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

  • Posts: 26251
  • Thank you received: 4040
  • MODERATOR
11 years 1 week ago #158167

Hi,

Yes, you have to set the additional every time the cart is loaded.
It means that you have to use the session to store your data and re-set the cart additional tip if there is something in the Joomla user session.

When the cart will be converted to an order at this moment the additional will be fixed in the database. But the additionals are not stored in the database (and so, the session) but HikaShop.
For the cart, it is dynamic fields managed by plugins.

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.

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

Time to create page: 0.057 seconds
Powered by Kunena Forum