Obtaining order id in Order Detail Template - prestashop

Is there a way to get the id of the order that is opened in order-detail.tpl
I am using this function with a set id instead of order_id but i need to make it so depending on what order details page is opened order_id to be equal to the id of that order.
Product::eprim_carrier_status("order_id")

It is not exactly clear in which context you want to get the order_id. In order-detail.tpl, you have object $order, which is an instance of OrderLazyArray. So in smarty template you can get the order id like this: $order.id_order.
But probably the easiest way to get it is to take it from $_GET parameters, as every link to order detail page has the id_order parameter. For example, when you open any order detail page, the URL looks like this:
http://yourprestasite.com/index.php?controller=order-detail&id_order=11.
In Prestashop, you get both $_GET and $_POST parameters by using the Tools::getValue('key'). So in your case:
$id_order = Tools::getValue('id_order')

Related

How can I control the placement of URL parameters in my route URL?

Suppose I'm creating a website to display customer orders. I want to have pages showing:
A list of customers, which allows me to drill down to...
A list of orders for a given customer, which allows me to drill down to...
Details of a particular order for the customer.
If I create a few Razor pages, I might end up with the following structure:
[Pages]
Index.cshtml
[Customer]
Index.cshtml
[Order]
Index.cshtml
The top-level page (list of customer) has no parameters, so the URL for that is just /.
The customer page (list of orders for a customer) needs a customer ID, so I can put #page "{customerId} at the top of the .cshtml file. It's URL will then be /Customer/123.
So far, so good. That URL makes sense.
Now for the order-detail page. This needs an order number, so let's put #page "{orderNo}" at the top of the .cshtml file. Its URL is... /Customer/Order/54321. Hmmm... I've lost the customer ID from the URL.
I can add the customer ID back in by making the #page directive include it (#page "{customerId}/{orderNo}"), but then the URL is /Customer/Order/123/54321 - which doesn't look good.
How could I get the URL to look like /Customer/123/Order/54321?
You can use an override route template to negate the path-based route that the framework generates. Override routes start with a leading /. In your example the solution is:
#page "/Customer/{customerid}/Order/{orderid}"
Note that this has the benefit of being robust in the face of changes to the structure of the site. You may, for example, decide in the future that nesting the Order folder within the Customer folder impedes discovery, but the override route will ensure that the page is found at the same URL regardless where you move the source files to within the Pages folder.

selenium issue:How to capture dynamic voucher number in a website

I have a website where two users (user15 and user16), user 15 creates a voucher which gets approved by user16. So in the home screen of user15 a voucher number is generated which is dynamic as shown in image below.I need to capture this voucher number generated for the one whose status is ""Processed" and then put it into the search filter of user16 homepage screen.How can i capture this dynamic voucher number ?
voucher number image
Your table template looks static. It is only the rows that are getting changes so you can write an xpath like below which would directly get you the voucher name:
//td[text()='Processed')]/preceding-sibling::td[colnumber of VoucherNubmer]
Please follow following steps mentioned below:
First select all elements from the table within the list.
Then using foreach loop compare the status of the element.
After that if(status=="Processed") then using getText() method print the value of the vochure number.

How do I update properties on a shopify line_item

How do I update the properties for a specific line_item using the shopify api?
There does not seem to be a method to directly update a specific line item.
I then tried to update the entire order object instead, but it seems like it is not saving my properties. If I save the order with the following json, the api returns the full order object, but with an empty properties [] line for my line_items.
{"order":{"id":94202342,"line_items":[{"id":615546756,"variant_id":627937216,"properties":[{"my_test_key":"This_is_a_test"}]}]}}
You can create a new order with the API but you can't update the line items of an existing order.
From the Order API docs:
You should also note that you can change only a few of an order's
attributes using the API. You cannot change the items or the
quantities in an order.

Custom meta title on checkout/success page in opencart

I am new to opencart and need help with oc 1.5.5.1
I am trying to call custom meta title to add last order id on checkout/success page. I have followed a very helpfull response from shadyyx on Opencart successful order ID and Total from JavaScript
Now I am stuck at a point on how to use the order_id which is already available in session and call / display it in meta title of checkout/success page.
As I understood you, you need to check if the orderid exists and not empty and route is checkout/success so for example add this to $this->data['my-new-metatag']
All above do in the common/header controller (cos meta tags are in the common/header tpl file)
then in common/header.tpl check if $my-new-metatag exists, echo it, otherwise leave variable that echos by default

Grails trouble saving object id

id is present in the params but does not save to the db. for example
[book.id:1, comments: good]
comments will save to db but book.id does not.
I need to figure out how to save params.book.id into the db column BOOK_ID that was created from the hasmany/belongsTo relationship.
By default value attribute of each element will be the result of a toString() call on each element. Setting it as optionKey allows the value to be a bean property of each element in the list.
Kindly change the select to
<g:form action="review">
<g:select name="book.id"
from="${item.Book.list()}"
value="${book?.id}"
/>
<g:textField name="bookreview" value="${params?.bookreview}" /><br>
kindly refer the below link
Grail example with optionkey
You have overwritten toString, therefore your books are always rendered by name and not id. If you remove your toString() method you will see the expected results.
If you want your select box work with the name, just add optionValue="name".
Well, it seems that I had misspelled a crucial parameter inside my domain. So the domain was expecting x and it was getting y. Thus the id was always null. It took me a while to spot it, and I was perplexed because I had previously successfully implemented ids in another project. Grails has some jira issues also that make one consider other possibilities, but this time it was my mistake.