Can't change points discount and used in order

  • Posts: 42
  • Thank you received: 0
8 years 8 months ago #231538

-- HikaShop version -- : 2.6.1
-- Joomla version -- : 3.4.8
-- PHP version -- : 5.5.50

Hi,

I would like to change the point discount and point used in the edit order page, but i can't a way to edit (see attached). There is a not of situation where you may need to change the point discount for the customer.

Regards,

Gary

Attachments:

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

  • Posts: 82867
  • Thank you received: 13374
  • MODERATOR
8 years 8 months ago #231574

Hi,

The current system doesn't support that, but it would be nice, so I've worked on it.
Add the code:

if(isset($data['order']['additional'])) {
				$task = 'products';
				$data['products'] = '1';
				$do = true;
			}
after the code:
if(isset($data['order']['order_payment_tax_namekey'])) {
				$order->order_payment_tax_namekey = $safeHtmlFilter->clean($data['order']['order_payment_tax_namekey'], 'string');
				$do = true;
			}
in the file administrator/components/com_hikashop/classes/order.php

Change the code:
if(empty($product->order_product_quantity)){
			return $this->delete($product->order_product_id);
		}
to:
if(empty($product->order_product_quantity) && @$product->order_product_code != 'order additional'){
			return $this->delete($product->order_product_id);
		}
in the file administrator/components/com_hikashop/classes/order_product.php
and change the code:
if(!empty($this->order->additional)) {
		foreach($this->order->additional as $additional) {
?>
		<dt class="hikashop_order_additional_additional"><label><?php echo JText::_($additional->order_product_name); ?></label></dt>
		<dd class="hikashop_order_additional_additional"><span><?php
			if(!empty($additional->order_product_price)) {
				$additional->order_product_price = (float)$additional->order_product_price;
			}
			if(!empty($additional->order_product_price) || empty($additional->order_product_options)) {
				echo $this->currencyHelper->format($additional->order_product_price, $this->order->order_currency_id);
			} else {
				echo $additional->order_product_options;
			}
		?></span></dd>
to:
if(!empty($this->order->additional)) { ?>
<input type="hidden" name="data[order][additional]" value="1"/>
<?php	
		foreach($this->order->additional as $additional) {
?><?php
			if(!empty($additional->order_product_price)) {
				$additional->order_product_price = (float)$additional->order_product_price;
			}
			if(!empty($additional->order_product_price) || empty($additional->order_product_options)) {
				$name = 'order_product_price';
				$value = $additional->order_product_price;
			} else {
				$name = 'order_product_options';
				$value = $additional->order_product_options;
			}
		?>
		<dt class="hikashop_order_additional_additional"><label><?php echo JText::_($additional->order_product_name); ?></label></dt>
		<dd class="hikashop_order_additional_additional"><span>
			<input type="text" name="data[order][product][<?php echo $additional->order_product_name; ?>][<?php echo $name; ?>]" value="<?php echo $value; ?>"/>
			<input type="hidden" name="data[order][product][<?php echo $additional->order_product_name; ?>][order_product_id]" value="<?php echo $additional->order_product_id; ?>"/>
			<input type="hidden" name="data[order][product][<?php echo $additional->order_product_name; ?>][order_product_code]" value="order additional"/>
			<input type="hidden" name="data[order][product][<?php echo $additional->order_product_name; ?>][order_product_quantity]" value="0"/>
		</span></dd>
in the file administrator/components/com_hikashop/views/order/tmpl/edit_additional.php
That will add that capability. We'll add that in the next version as well.

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

  • Posts: 42
  • Thank you received: 0
8 years 8 months ago #231788

Hi Nicolas,

Thank you for the help and it is a nice improvement. However, it doesn't cover a situation (very common situation) when the customer does not use point when submitting the order but wants it afterward. The point fields are not there so there is no place i can add the points and discount. Can yo make the fields visible to all situations so i can add or remove points and discount if needed?

Regards,

Gary

Attachments:

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

  • Posts: 82867
  • Thank you received: 13374
  • MODERATOR
8 years 8 months ago #231810

Hi,

We can't do that by default.
The problem is that the additional system field can be used by other things than user points. So HikaShop doesn't know what fields should or shouldn't be there and there is no system for plugins to tell it that.

What you can do is add that at the beginning of that view in order to cheat but we can't add that by default:
<?php if(empty($this->order->additional)){
$points1 = new stdClass();
$points1->order_product_price = 0;
$points1->order_product_name = 'Points discount';
$points1->order_product_id = 0;
$points2 = new stdClass();
$points2->order_product_options = '0 Points';
$points2->order_product_name = 'Points used';
$points2->order_product_id = 0;
$this->order->additional = array($points1,$points2);
} ?>

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

  • Posts: 42
  • Thank you received: 0
8 years 8 months ago #231944

Hi Nicolas,

I applied your codes in view/order/edit-additional, is that right? the two additional fields appear and i am able to input the points and discount. But the problem is that the change only appears in the backend and the customer doesn't see the change when he click "view your orders" in the control panel, what he sees is a wrong total calculation.

I also found out that when i edit the coupon amount, it only accepts positive amount, so rather than subtracting it adds.

Due to the fact that your userpoint payment plugin doesn't meet my requirement, i can't let my customer to apply the point in the frontend and that's OK because I thought i can apply the point discount for them in the backend and I can't. Please let me know the way to solve this problem.

Regards,

Gary

Attachments:

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

  • Posts: 82867
  • Thank you received: 13374
  • MODERATOR
8 years 8 months ago #231948

Hi,

Note that we're far from user support here. That's custom development.

So the points information is taken into account in the backend ? You get the correct total in the backend ? What about the emails and invoice ? Do it display properly ?
Do you get the points to display properly on the frontend when they aren't added from the backend ?
If you check the hikashop_order_product table in your phpmyadmin, you'll see there the lines for the products of the orders, and the lines for the points. What is the difference between the points added through the backend and the points added through the frontend ? That would help us understand what's missing.

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

  • Posts: 42
  • Thank you received: 0
8 years 8 months ago #232079

HI Nicolas,

The last code you gave seems to work at first but the points then are gone if i edit something else. I have check the table Hikashop_order_product, i don't see the field points there.

What's wrong with the coupon field, it won't take negative amount.

Gary

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

  • Posts: 82867
  • Thank you received: 13374
  • MODERATOR
8 years 8 months ago #232117

Hi,

1. What do you mean by "it works" ? You get the points and the discount in the order like you're expecting ?
What do you mean by " the points then are gone if i edit something else" ? Do you ahve the problem when you edit the address ? When you edit a product of the order ? When you edit the additinals ?
You say "I have check the table Hikashop_order_product, i don't see the field points there."? But do you have them before you edit something else ? (it's not possible that you don't have them actually or you wouldn't see the points in the order as the information is stored there)
Could you provide some screenshots ?

2. I don't have a problem with adding a negative value in the coupon of an order:
take.ms/A2kHN
take.ms/h9mwW

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

  • Posts: 42
  • Thank you received: 0
8 years 8 months ago #232555

Hi Nicolas,

Please see the attachments for explanation.

attachment 1-3, you can see the points are gone after i have updated the product quality.

attachment 4-5, you can see that the coupon amount is added rather than subtraction.

Please let me know the problems.

Regards,

Gary

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

  • Posts: 82867
  • Thank you received: 13374
  • MODERATOR
8 years 8 months ago #232580

Hi,

1. Could you also please answer all my questions so that we get a better understanding of what's going on ?
Do you ahve the problem when you edit the address ? When you edit a product of the order ? When you edit the additinals ?
Do you also have the problem if you just save the product information without changing it ?


2. You're getting it backward. The coupon amount is subsctracted. The problem is that you set a negative value for your coupon.
So 100 - - 50 = 150 and not 50. You need to add a positive value in your coupon if you want to reduce the total amount since the coupon value is substracted.

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

Time to create page: 0.078 seconds
Powered by Kunena Forum