How do I access the current order id in opencart and put it in a variable? I am working in a new file, which did not come with the standard opencart install.
The closest I have been able to get is the following code, which doesn't work:
<?php
session_start();
$order_id = $this->session->data['order_id'];
?>
Thanks in advance.
The order ID isn't set until the customer gets to the final page of the checkout process, so you won't be able to get it before that. For your code above, you can't use $this->session->data['order_id'] unless you are in an opencart class, therefore you would need to use $_SESSION['order_id']
Related
This page: /my-account/view-order/132616/
... is associated with the view-order.php template file under the my account section. I am able to edit this by going directly into the woocommerce plugin dir, but copying the file into /my-child-theme/woocommerce/myaccount/view-order.php does not have any effect. I am able to edit the orders.php template in this manner, but not this one. I haven't been able to find any answers online to this one: why some of these template files can be copied / overwritten and some cannot be? Also, there appears to be limited scope on applying a hook to manipulate the content on this page. What I want to do, is turn the product names listed here into links back to the products in the store. Thanks for any help!
turns out this doesn't satisfy my need since the content I'm trying to manipulate is in the woocommerce_view_order do_action. Now I'm on the hunt for a filter hook.
Thanks for everyone in advance.
I encountered a problem when using Scrapy on Python 2.7.
The webpage I tried to crawl is a discussion board for Chinese stock market.
When I tried to get the first number "42177" just under the banner of this page (the number you see on that webpage may not be the number you see in the picture shown here, because it represents the number of times this article has been read and is updated realtime...), I always get an empty content. I am aware that this might be the dynamic content issue, but yet don't have a clue how to crawl it properly.
The code I used is:
item["read"] = info.xpath("div[#id='zwmbti']/div[#id='zwmbtilr']/span[#class='tc1']/text()").extract()
I think the xpath is set correctly and I have checked the return value of this response and it indeed told me that there is nothing under this directory. Results shown here:'read': [u'<div id="zwmbtilr"></div>']
If it has something, there should be something between <div id="zwmbtilr"> and </div>.
Really appreciated if you guys share any thoughts on this!
I just opened your link in Firefox with NoScript enabled. There nothing inside the <div #id='zwmbtilr'></div>. If I enable the javascripts, I can see the content you want. So, as you already new, it is a dynamic content issue.
Your first option is try to identify the request generated by javascript. If you can do that, you can send the same request from scrapy. If you can't do it, the next option is usually to use some package with javascript/browser emulation or someting like that. Something like ScrapyJS or Scrapy + Selenium.
I use opencart version 2.1.0.1
Everytime I click admin > sales > order, it will pop up "error undefined." By closing that popup window, I can still edit order but cannot delete order (no response).
In my log, there is:
PHP Notice: Undefined variable: order_id in
/var/www/html/opencart2101/system/storage/modification/admin/view/template/sale/order_list.tpl on line 821
The line 821 is:
url: 'index.php?route=extension/openbay/addorderinfo&token=<?php echo $token; ?>&order_id=<?php echo $order_id; ?>&status_id=' + status_id,
However, I haven't installed any openbay related module. Also, line 821 is inside <!-- --> mark. It should have no effect.
Help!
Although this is now an older version of opencart, I still see this being reported a lot around and about.
The problem occurs due to the store front adding the http url rather than the https url to the order. So firstly you need to fix that. If you dont want to read all of my explanation, you can just hit up the bold points :)
Either way BACKUP EVERYTHING actually not really, back up the file you are going to edit and backup your whole database.
open:
catalog/controller/checkout/confirm.php at around line 100
Find:
$order_data['store_url'] = HTTP_SERVER;
Change to:
$order_data['store_url'] = HTTPS_SERVER;
Now you will want to fix your database because for reasons I cannot fathom, the domain name is placed in the order along with the stores id. and when editing orders it is the usage of that directly within your admin order page that throws up the undefined notice. Basically the browser blocks the request because its trying to make an insecure request from a secure page.
Crack open phpmyadmin or whatever database tool you have on hand.
locate the table, default is oc_orders
Browsing the table, look for the column that contains your store url (i cant remember the name off hand, i think its just store_url but it will be obvious anyway. if you are multi store you will need to run the query for each
I am sure somebody can come up with a clever way to automatically convert just the http into https with a single use sql query on the one column, but this works for me.
Run SQL: adjust as appropriate
UPDATE `oc_orders` SET `store_url` = 'https://example.com' WHERE store_id = 0;
Can Any One Please Tell Me
how to put opencart 2.0 customer first name and last name on header?
I Am Already Use this Code For Opencart 1.5.6 Working Fine But In 2.0 Getting Error
$this->customer->getFirstName(); ?> $this->customer->getLastName(); ?>
But ThisCode Is Not Working For 2.0 Version
I Am Getting This Error : Undefined property: Loader::$customer in header.tpl
Please Help Me Any One
Thanks
To fix this error you need to call them in the controller instead of in the template.
In catalog/controller/common/header.php add the following code inside the index() function:
$data['customer_firstname'] = $this->customer->getFirstName();
$data['customer_lastname'] = $this->customer->getLastName();
In catalog/view/theme/your-theme/template/common/header.tpl you can echo the first and last name:
echo $customer_firstname;
echo $customer_lastname;
Note that it is better not to edit Opencart core files. Instead you can use VQMod to implement the changes in the header controller.
Good day!
Could you help me to figure out how to customize joomla 2.5 template. The problem is that main(index page) shouldn't contain header block, but other pages should. Is there any solution for this (maybe somewhere in administration panel located this option). Sorry for my bad english and pure knowledge of joomla.
It could help if you could show me your site,
but one easy option would be to use following to test for front page in your template:
<?php
$app = JFactory::getApplication();
$menu = $app->getMenu();
if ($menu->getActive() == $menu->getDefault()) {
echo 'This is the front page';
}
?>
another option would be to prevent all header modules from showing on the front page (if your header is made of modules)
You could use two different templates and assign one of them to your front page and make the second one default, so it will be assigned to the rest of your pages. However, you wouldn't normally do that if the only thing that's different is the presence of the header and everything else (like layout, colors, shapes, etc.) is the same.
In your case it makes more sense to implement your header as a module (use "Custom HTML" module type) and set it up to only display on the front page.
Good luck!
удачи!