massaction with several orders to copy

  • Posts: 239
  • Thank you received: 3
  • Hikashop Business
7 months 22 hours ago #333734

-- HikaShop version -- : 4.4.3
-- Joomla version -- : 3.9.26
-- PHP version -- : 7.4.20

Hello Team,

I have made a massaction, with a filter on the product code and several actions to reset, configure the orders using the copy function from the administration order list.
We are a teaching center, each order only contains one product, which is a certain course.
What we are looking for with this massaction is that the students who pass the course receive pre-registration for the next year's course.
We use your system as follows:

1.- We enter the code of a specific course in the search engine for the list of orders on the backend, thus showing us the list of students that correspond to that course. (We have made the pertinent modifications in this view order / listing.php of the administration and in the file admin / components / com_hikashop / views / order / view.html.php, so that this search and listing can be carried out through the product code search.)

2.- The code of each course begins with the last digit of the year in question. In this case, the students of the year 2020 always begin with 0. Those of the current year 2021, begin with 1.

In the list obtained, we select the students who pass the course, and we make a copy of that selection.

This is where we use the massaction, which is the following:

Event trigger: after an order is created
Fiter: order_product_code start by 0
Update values: order_payment_price = 0
Update values: order_full_price = 0
Update values: order_payment_id = 4
Udpdate values: order_shipping_id = 3
Update values: order_product_quantity = 0
the latter is to empty the product of the order



In this way, the values ​​we want are reset and we remove the product that corresponds to last year.

When we use the massaction by copying the orders 1 by 1, it works correctly and we obtain the desired result, but if we select several orders at the same time that it is our desire, it does not make any modification, simply copy it with the existing values.

3.- Once the new code for the current course has been copied and inserted, in this case 2021, it is manually placed in provisional status.

Are we performing any of the steps in the wrong way, or can a modification be implemented, so that when selecting several values ​​the massaction is effective?

4.- After this massaction, we carry out another one, to send the status change email:

Event trigger: after an order is created
Filter: provisional status
Filter: order_product_code starts by 1
Action change status to pre-registration with sending email





Thank you very much for your help

Attachments:

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

  • Posts: 74595
  • Thank you received: 11508
  • MODERATOR
7 months 5 hours ago #333765

Hi,

I see what you're doing and why it doesn't work.
In the mass action system, we have a security mechanism so that if you create an action with a specific trigger, you can't trigger it a second time on the same page process.
That's to avoid someone creating a mass action with a trigger "after an order is updated" or "after a product is updated" and generating a loop by having an action updating the order / product and thus retriggering the mass action.
But in the case of a copy, that's indeed a problem.
So I've been working on this today and I've made a patch so that there is still a security mechanism, but instead of preventing a second trigger on the same page, it prevents a second trigger in the same trigger. And since each copy is triggered independently, it now works for all the copies made with the same copy button click.
To get the patch, download the install package of the current version of HikaShop on our website and install it on yours.

The following user(s) said Thank You: dvddvd

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

  • Posts: 239
  • Thank you received: 3
  • Hikashop Business
6 months 3 weeks ago #334102

Hello Nicolás, funny everything is correct and your help is invaluable.
In spite of everything I have the following problems that I have not been able to solve.
1.- The page as I indicated before is a university and sells courses, therefore the orders are restricted to a single product.
When the copy of the orders of the students who pass the course is made, we wanted it to reset several fields, leaving the user's data ready to add the new course.
a.- We would love that in the product selector within the order, we could search by the product code.




b.- As to remove the course from the previous year, we use a massaction that reads order_product_quantity = 0 in an event trigger after an order is created, in the order view, which is modified, so that each order has only one product and show us the product code, each product of the order appears repeated, although in the product that changes by zero (last year's courses), its quantity is zero. Is it possible to delete products with zero quantity using a mass action? I have tried using run MySQLquery: DELETE FROM xxxx_hikashop_order_product WHERE order_product_quantity = 0, but I can't get it to work.



Greetings and thank you

Attachments:

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

  • Posts: 74595
  • Thank you received: 11508
  • MODERATOR
6 months 2 weeks ago #334117

Hi,

1.a. You can also search by product code. Just start typing the product code in the input area and you'll see the product(s) with what you typed contained in either the product name or the product code appear in the selector below.

1.b. You can run such MySQL query, yes.
If it doesn't work, the issue might be that your mass action doesn't find any elements and thus, when no elements are found after the filtering, the actions are not run.

The following user(s) said Thank You: dvddvd

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

  • Posts: 239
  • Thank you received: 3
  • Hikashop Business
6 months 2 weeks ago #334120

Thanks Nicolas:

One more thing, how can I put the price of the new product through the massaction in the order full price, since it remains the price of last year's product.

It seems that it only modifies the total price of the order in the first item selected, when add the product on actions, after coping.

A cordial greeting

Last edit: 6 months 2 weeks ago by dvddvd.

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

  • Posts: 74595
  • Thank you received: 11508
  • MODERATOR
6 months 2 weeks ago #334127

Hi,

You can use an action "update the values" on the column "order_full_price" with the mode "operation" and the value:
order.order_full_price+xxx
where xxx is the additional cost compared to before.

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

Time to create page: 0.095 seconds
Powered by Kunena Forum