When an admin creates an order (at admin/orders/store/create) the node checkout node must be linked to the order. Node checkout is already prepared for this and once the order is complete and you click the View tab it displays a message and links to “Create node association”. This link, however, doesn't work.
As a simple example let's say that we have events and attendees, so that when you register for an event you need to create a node with attendee details.
If you look at the link mentioned about you’ll notice it includes the order id, product id, and order product, like this:
node/add/attendee?order_id=123&product_id=456&order_product_id=789
However, node checkout misses those parameters and redirects to the pick-a-product page and then if you pick the same product/event (with id 456) it never links back to the existing order and creates a new cart item instead.
This is caused by the following bug:
When you create an event and add an attendee, there is a GET variable “product_nid”, as in node/add/attendee?product_nid=456. Function uc_node_checkout_form_alter will use it to link the attendee to the event.
However, when you try to do the same from the order page, the variable is “product_id”, as in node/add/attendee?order_id=123&product_id=456&order_product_id=789. Function uc_node_checkout_form_alter will not be able to use it as the variable “product_nid” is not present.
We have two ways of resolving this:
a) Change the link for order so that is becomes node/add/attendee?order_id=123&product_id=456&product_nid=456&order_product_id=789, in line 1195 of uc_node_checkout.module file, which is not very elegant.
b) Change the uc_node_checkout_form_alter function so that instead the following code on line 347:
elseif (!empty($_GET['product_nid'])) {
// Otherwise look in the $_GET array.
$product_nid = $_GET['product_nid'];
}it uses
elseif (!empty($_GET['product_nid'])) {
// Otherwise look in the $_GET array.
$product_nid = $_GET['product_nid'];
}
elseif (!empty($_GET['product_id'])) {
// For manually created orders the element is product_id
$product_nid = $_GET['product_id'];
}| Comment | File | Size | Author |
|---|---|---|---|
| #1 | uc_node_checkout-associations-1403178.patch | 669 bytes | sokrplare |
Comments
Comment #1
sokrplare commentedThe second change described above is in the attached patch.
Comment #2
tr commentedFixing status.