Wrap the articles as a gift

  • Posts: 62
  • Thank you received: 0
  • Hikashop Business
9 years 5 months ago #178507

-- HikaShop version -- : 2.3.4
-- Joomla version -- : 2.5.24

In my shop there is the possibilty to wrap the articles as a gift. The costs are 1 euro. With the customfield in the table order, is it possible to add an extra field (checkbox) in the checkout with the question 'do you want the articles wrapped as a gift?'. The only problem is that when someone checks this the cart total should be added with 1 euro. How can I do this?
regards,
Joost

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

  • Posts: 13201
  • Thank you received: 2322
9 years 5 months ago #178529

Hi,

You will have to do a plugin for that.
Based on the function "onAfterCartShippingLoad()", create an object like that:

			if(isset($cart->order_currency_id))
				$currency_id = $cart->order_currency_id;
			else
				$currency_id = hikashop_getCurrency();

			$wrap = new stdClass();
			$wrap->name = 'WRAP_ARTICLE';
			$wrap->value = '';
			$wrap->price_currency_id = $currency_id;
			$wrap->price_value = 1;
			$wrap->price_value_with_tax = 1;
			$cart->additional['wrap'] = $wrap;
if the checkox is checked, you can verify that in the "$cart" object in the function.

You can see how it's working in the "plugins/hikashoppayment/userpoints/userpoints.php" file.

Here is some developer documentation:
hikashop.com/support/support/documentati...r-documentation.html

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

  • Posts: 62
  • Thank you received: 0
  • Hikashop Business
9 years 5 months ago #178935

Hi Xavier,
I have spend time to get it working but it's a pity... not working. I have got the checkbox in the cart-part. So that's ok. The column name in the ' custom fields' is called 'artikelenalskadoinpakken '.
I have got the following code in my plugin, but there must be something wrong... Can you please help me, make it working?
regards,
Joost

<?php
/**
 * @package	HikaShop for Joomla!
 * @version	2.3.4
 * @author	hikashop.com
 * @copyright	(C) 2010-2014 HIKARI SOFTWARE. All rights reserved.
 * @license	GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */
defined('_JEXEC') or die('Restricted access');
?><?php
class plgHikashoppaymentWrap extends hikashopPaymentPlugin {
	var $multiple = true;
	var $name = 'wrap';
	var $accepted_currencies = array();

		function onAfterCartShippingLoad(&$cart) {
		$app = JFactory::getApplication();
		$artikelenalskadoinpakken = (int)$app->getUserState(HIKASHOP_COMPONENT.'.artikelenalskadoinpakken', 0);

if(isset($cart->order_currency_id))
 $currency_id = $cart->order_currency_id;  else  $currency_id = hikashop_getCurrency();

$wrap = new stdClass();
$wrap->name = 'WRAP_ARTICLE';
$wrap->value = '';
$wrap->price_currency_id = $currency_id;
$wrap->price_value = 1;
$wrap->price_value_with_tax = 1;
$cart->additional['wrap'] = $wrap; 

}
}

Attachments:

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

  • Posts: 13201
  • Thank you received: 2322
9 years 5 months ago #178984

Hi,

Please try that code instead:

<?php
/**
 * @package	HikaShop for Joomla!
 * @version	2.3.4
 * @author	hikashop.com
 * @copyright	(C) 2010-2014 HIKARI SOFTWARE. All rights reserved.
 * @license	GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */
defined('_JEXEC') or die('Restricted access');
?><?php
class plgHikashoppaymentWrap extends hikashopPaymentPlugin {
	var $multiple = true;
	var $name = 'wrap';
	var $accepted_currencies = array();

	function onAfterCartShippingLoad(&$cart) {
		if(!isset($_POST['data']) || !isset($_POST['data']['order']['artikelenalskadoinpakken'][0]))
			return;
			
		if(isset($cart->order_currency_id))
		 $currency_id = $cart->order_currency_id;  else  $currency_id = hikashop_getCurrency();

		$wrap = new stdClass();
		$wrap->name = 'WRAP_ARTICLE';
		$wrap->value = '';
		$wrap->price_currency_id = $currency_id;
		$wrap->price_value = 1;
		$wrap->price_value_with_tax = 1;
		$cart->additional['wrap'] = $wrap; 
	}
}

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

  • Posts: 62
  • Thank you received: 0
  • Hikashop Business
9 years 5 months ago #179095

Hello XAvier,

Unfortunately it isn't working. When I check the checkbox 'artikelenalskadoinpakken' nothinh happened. So there is not 1 euro added to the cart....
Help!

regards,
Joost

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

  • Posts: 26013
  • Thank you received: 4004
  • MODERATOR
9 years 5 months ago #179177

Hi,

For sure it's not working ; that's not the way to read the value of an order custom field.

class plgHikashopWrap extends JPlugin {
	function onAfterCartShippingLoad(&$cart) {
		$app = JFactory::getApplication();
		$order_fields = $app->getUserState(HIKASHOP_COMPONENT.'.checkout_fields', null);
		
		if((int)$order_fields->artikelenalskadoinpakken == 0)
			return;

		if(!empty($cart->order_currency_id))
			$currency_id = (int)$cart->order_currency_id;
		else
			$currency_id = (int)hikashop_getCurrency();

		$wrap = new stdClass();
		$wrap->name = 'WRAP_ARTICLE';
		$wrap->value = '';
		$wrap->price_currency_id = $currency_id;
		$wrap->price_value = 1;
		$wrap->price_value_with_tax = 1;
		$cart->additional['wrap'] = $wrap; 
	}
}

Please understand that it going away from the support we are providing for HikaShop.

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.

  • Posts: 62
  • Thank you received: 0
  • Hikashop Business
9 years 5 months ago #179274

Hello Jerome,

I understand that I am asking a lot. If you want me to pay for the excellent support, no problem! I want this get it working as soon as possible.
For now it is still not working. When I select/deselect the checkbox no change in the cart...

regards,
Joost

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

  • Posts: 26013
  • Thank you received: 4004
  • MODERATOR
9 years 5 months ago #179281

Hi,

When I wrote the plugin I test it in my local website and it's working fine.
The problem is not in the code.

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.

  • Posts: 62
  • Thank you received: 0
  • Hikashop Business
9 years 5 months ago #179628

Hi Jerome,

Thanks for you effort so far! I appreciate that!
It drives me nuts... I don't know what the problem is.... Attached I have a screendump of my 'custom field'. I think there must be something wrong with this....
I hope you can help me get this 'thing' working.

regards,
Joost

Attachments:

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

  • Posts: 26013
  • Thank you received: 4004
  • MODERATOR
9 years 5 months ago #179632

Hi,

Your custom field does not have values (Waarde) for the element.
So even if the user check the checkbox, the value behind will be empty, so no possibility to know if the user have check or not the custom field.

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.

  • Posts: 62
  • Thank you received: 0
  • Hikashop Business
9 years 5 months ago #179719

Hi Jerome,

I had also tried it before with a value of '1' but also then there is no change in the cart. Maybe you can check it yourself: I can sent you superadmin credentials.

Regards,
Joost

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

  • Posts: 26013
  • Thank you received: 4004
  • MODERATOR
9 years 5 months ago #179748

Hi,

It should work.
Are you really sure that the plugin is right installed and published in your website ?
I do not found it in the Joomla plugin manager.

Please understand that it going away from the support we are providing for HikaShop.


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.

  • Posts: 62
  • Thank you received: 0
  • Hikashop Business
9 years 5 months ago #179819

HEllo Jerome,

I have install it again and it was visible in the pluginmanager, but the site didn't work then at all... It makes me nuts.... How much will it cost to let you fix this? And how can we arrange this?

regards,
Joost

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

  • Posts: 26013
  • Thank you received: 4004
  • MODERATOR
9 years 5 months ago #179851

Hi,

Your plugin won't work ; It has wrong category+name regarding his classname.
docs.joomla.org/J3.x:Creating_a_Plugin_for_Joomla

If you want ask for custom job, please use the "contact us" form.

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.100 seconds
Powered by Kunena Forum