User Points - HikaSerial Consumer plugin

  • Posts: 15
  • Thank you received: 0
9 years 1 month ago #192752

-- HikaSerial version -- : 1.9.0
-- Joomla version -- : 3.3.6
-- PHP version -- : 5.5.19

I have created a product, a User Points - HikaSerial generator, a serial pack and a User Points - HikaSerial Consumer plugin.

When I login to the front end and buy a product, a serial is generated like expected with the specified number of points in the Serial Extra Data of the serial.

When I try to consume the serial using:
http://localhost/joomla/index.php?option=com_hikaserial&ctrl=serial&task=consume&hikaserial[serial_data]=YOUR_SERIAL&hikaserial[serial_extra_data][myUser]=YOUR_USERNAME&hikaserial[format]=json

The status of the serial changed to USED but the number of points on the serial does not change.

What am I doing wrong?

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

  • Posts: 26000
  • Thank you received: 4004
  • MODERATOR
9 years 1 month ago #192757

Hi,

Do you have the "points consumer" plugin activated and configured ?
With which account do you call the consume URL ?

Usually, the points serials are consumed during the checkout or thanks to the "consume" module.
In the checkout workflow you can replace the "coupon" block by the "hikaserial coupon" one ; this block allow you to consume serials and also add coupon codes.
So if a customer enter a points serial during the checkout, he will be credited for the points.

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: 15
  • Thank you received: 0
9 years 1 month ago #192780

I have attached the plugins and it shows that I have the "points consumer" activated
I also attached the configuration of the consumer

I only tried it with the administrator account for now.
The idea is to consume the serial from an outside application using the webservice:

index.php?option=com_hikaserial&ctrl=serial&task=consume&hikaserial[serial_data]=YOUR_SERIAL_DATA&hikaserial[serial_extra_data][myUser]=YOUR_USER_NAME&hikaserial[format]=json

Attachments:

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

  • Posts: 26000
  • Thank you received: 4004
  • MODERATOR
9 years 1 month ago #192784

Hi,

Unfortunately, the way that the point consumer is working, it try to add the points to the current logged user.
It will require some modifications in the plugin (or a copy of the plugin) in order to apply the points to a target user.

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: 15
  • Thank you received: 0
9 years 1 month ago #192899

Hi Jerome,

Thank you for your help.

I traced the php_error_log and I found the following:
[03-Mar-2015 08:42:32 Europe/Berlin] PHP Notice: Undefined property: plgHikaserialPointsgen::$main_currency in C:\xampp\apps\joomla\htdocs\plugins\hikaserial\pointsgen\pointsgen.php on line 186

Code from pointsgen.php:


if($this->main_currency != $order_currency_id)
$product_price = $currencyClass->convertUniquePrice($product_price, $main_currency, $order_currency_id);

$serialObj->extradata += (int)($product_price / $v);

So it seems that somehow the main_currency is not defined for the above code.
I have attached the Hikashop configuration page where you can see that the main currency is indeed configured.

What am I missing?

Attachments:

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

  • Posts: 26000
  • Thank you received: 4004
  • MODERATOR
9 years 1 month ago #192926

Hi,

Thanks for the report ; it is strange that I didn't have the issue last time I tested it.
Please edit the plugin and replace in line 186

if($this->main_currency != $order_currency_id)
By
if($main_currency != $order_currency_id)
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: 15
  • Thank you received: 0
9 years 1 month ago #193049

I tried to trace the code to see why the points are not being added.
In the pointsonsumer.php under the function givePoints, the function exited in the highlighted line below before actually giving the points. So it seems that the user_points is not set. What does that mean? Is it possible that I am missing something in the configuration?

		if($points_mode == 'hks') {
			if(hikaserial::initShop()) {
				$app = JFactory::getApplication();
				$ret = true;

				$userClass = hikaserial::get('shop.class.user');
				$oldUser = $userClass->get($user_id, 'cms');

				if(!isset($oldUser->user_points)) // -- INCRIMINATED LINE
					return false;
				if(empty($oldUser->user_points))
					$oldUser->user_points = 0;

				$user = new stdClass();
				$user->user_id = $oldUser->user_id;
				$user->user_points = (int)$oldUser->user_points + $points;
				if($user->user_points < 0) {
					$app->enqueueMessage(JText::_('CANT_HAVE_NEGATIVE_POINTS'), 'error');
					$points = -$oldUser->user_points;
					$user->user_points = 0;
					$ret = false;
				} else {
					$app->enqueueMessage(JText::sprintf('HIKAPOINTS_EARN_X_POINTS', $points), 'success');
				}
				$userClass->save($user);
				return $ret;
			}
			return false;
		}

Last edit: 9 years 1 month ago by Jerome. Reason: [code] is nice

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

  • Posts: 26000
  • Thank you received: 4004
  • MODERATOR
9 years 1 month ago #193101

Hi,

I see.
There was a similar issue in HikaShop user points plugins and it looks like the patch as not been applied here.
Please use that test insteand.

	if(!isset($oldUser->user_points) && !in_array('user_points', get_object_vars($oldUser)))
		return false;
It will solve the issue.

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: 15
  • Thank you received: 0
9 years 1 month ago #193691

Dear Jerome,

Sorry for the late response.

I have tried your suggestion, however, it still does not work.

During the givePoints method (line 117 pointsconsumer.php), the value for :
$oldUser = stdClass and
$oldUser->user_points = null

Such that the function exits immediately after line 117 during condition testing and the user_points are not changed.

Any further suggestions are greatly appreciated.

Best Regards

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

  • Posts: 26000
  • Thank you received: 4004
  • MODERATOR
9 years 1 month ago #193707

Hi,

I'm sorry but I don't understand your message.

- The patch I gave you fixed the issue in HikaShop so I think it will also fix the same issue in HikaSerial.
- Yes your user does not have any points but the plugin will convert this "null" into "0"

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: 15
  • Thank you received: 0
9 years 1 month ago #193709

Hi Again,

Let me put it simply that the "User Points - HikaSerial Consumer plugin" is not working as expected. My expectation is that once the produced serial is used, the Consumer plugin will also change the points on the affected serial and that does not happen.

I also tried the same configuration on the Hikashop Demo site and I was unable to make it to work.

Can you provide a working sample setup of the plugin say in Hikashop demo?

I really appreciate your time and trouble.

Many Thanks.

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

  • Posts: 26000
  • Thank you received: 4004
  • MODERATOR
9 years 1 month ago #193712

Hi,

I start to wonder why people said that the HikaShop patch was fixing the issue....
Please use that code:

if(!isset($oldUser->user_points) && !in_array('user_points', array_keys(get_object_vars($oldUser))))
I'll see to patch HikaShop too.

Sorry for the inconvenient.

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: 15
  • Thank you received: 0
9 years 1 month ago #193713

Hi Jerome,

Thanks for your time. Alas, it still does not work. The "points_value" of the affected serial does not get modified during the "consumption" of that particular serial!

Awaiting a working example please.

Best Regards

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

  • Posts: 26000
  • Thank you received: 4004
  • MODERATOR
9 years 1 month ago #193716

Hi,

The "points values" in the serial should not be modified.
The serial just become "used" and the user got the points.

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: 15
  • Thank you received: 0
9 years 1 month ago #193727

In the documentation of "User Points - HikaSerial Generator plugin", it has the following:
Points value - The number of points which will be attached to the serial.

In the documentation of "User Points - HikaSerial Consumer plugin", it has the following:
Points value - You can define a fixed number of points that the user will gain while consuming a serial from the selected pack.

In the pointsconsumer.php file, under the givePoints function, there is the following line:
$user->user_points = (int)$oldUser->user_points + $points;

I already acknowledged the fact that the serial becomes "used" like you also reiterated.

In your last sentence:
The serial just become "used" and the user got the points.

So the expectation is that those points defined in the consumer plugin will be added to the points earned during the serial generation. This is what the documentation and the code lead to.

Where am I wrong?
If I am wrong, then what are the points in the serial used for?

Thanks again.

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

  • Posts: 26000
  • Thank you received: 4004
  • MODERATOR
9 years 1 month ago #193729

Hi,

www.hikashop.com/support/documentation/i...tsconsumer-form.html
I think you missed the last setting in the documentation

Dynamic value - You can say that the pack contains serial with points (generated by the "points generator").


You can use the points consumer plugin to give a fixed number points while consuming a serial from a specific pack.
You can also use the points consumer with serials generated by the points generator and give a dynamic number of points ; where the value of the points will be stored in the "additional" section of the serial (and will be added to the fixed value).

At to talk with code:
$points = (int)$this->plugin_params->value;
if(!empty($this->plugin_params->dynamic_value) && !empty($serial->serial_extradata['points_value']))
	$points += (int)$serial->serial_extradata['points_value'];
$this->givePoints($cms_id, $points);

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: 15
  • Thank you received: 0
9 years 1 month ago #193808

Dear Jerome,

Thank you for your patience.
I understand from the code that eventually, it is the user who is supposed to receive the points.

How do I configure the user to receive such points?

I need a serial that would allow the user to use the product for a given number of times and then expires.
It seems to me that the points generator/consumer is not meant for that kind of function, am I right?
Is there a different generator/consumer that will do something similar to what I need?

Many Thanks

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

  • Posts: 26000
  • Thank you received: 4004
  • MODERATOR
9 years 1 month ago #193826

Hi,

The goal of the "point consumer" is to give points to the user who consume the serial. Nothing more.
There is no "counter" feature in HikaSerial but it is possible to implement it using a custom plugin.
During the consumption, a plugin can specify what will be the future status of the serial.

$serialConsumed->serial_status = $used_status;
if(!empty($serial->status))
	$serialConsumed->serial_status = $serial->status;
So if in the trigger "onBeforeSerialConsume", a plugin set a value for the " $serial->status ", it will be use instead of the "used" status.
Thanks to that, you can create a "counter" plugin, using some data from the serial extra data.
Some other plugins are using the extra data for their processing, like the "points" or "time limited" ; you can use them as example.

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.
The following user(s) said Thank You: Rajaft

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

  • Posts: 15
  • Thank you received: 0
9 years 1 month ago #193846

Hi Jerome,

I think that would be the better solution. I will do as you suggested and update you.

Thank you again for all your help

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

  • Posts: 15
  • Thank you received: 0
9 years 1 month ago #194037

Hi Jerome,

I wanted to update you that I already built the plugin the way you suggested and it is working nicely. Thanks again for the help.

I have, I hope, one last question: in order to consume the serial, the user has to be logged in. However, if I am consuming the serial from an external application, how can I perform the login?

Thanks

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

Moderators: Obsidev
Time to create page: 0.095 seconds
Powered by Kunena Forum