how to execute a query in magento when order is successfull - php

Im new to magento,
I need to execute a query to insert a flag into orders table of magento when an order is successful (i.e returned from payment page), Ive found the front end files, but not sure where to place the code to execute this simple query, Im not comfortable with folder structure of magento.
Im using magento 1.7 currently
Please help me if you know where is the controller file to achieve this, if you can give me the file paths and class names it will be much helpful for me to uderstand this.

You need to get the event for OrderAfterSave, In observer file, you will get the last order id by using that you could insert flag.
Here is the link to tutorial. Hope this will help
http://blog.decryptweb.com/event-observer-magento/

You should use an Observer for this as it is the cleanest method as you do not have to rewrite any core files.
See http://www.nicksays.co.uk/magento-events-cheat-sheet-1-7/ for a full list of observers in Magento 1.7
See http://www.magentocommerce.com/wiki/5_-_modules_and_development/0_-_module_development_in_magento/customizing_magento_using_event-observer_method for more information about using observers.
If you want to observer the order success action I would use checkout_onepage_controller_success_action there are many others regarding orders, something like checkout_type_onepage_save_order_after as it will give you access to the order object which you will not have to reinitialize.

Related

How to capture opencart (1.5.1) order confirm event?

When confirm(...) (in order.php) is called by a payment method module how can I get notification of this event and run my own method to process the data for an accounting module(I need to parse the order and send it to quickbooks)?
I am aware I could place a call in the confirm method. However, because of the license I want to avoid modifying anything in the OpenCart code.
Anyone know how to hook into OpenCart order confirm events? Is there a built-in means of notification?
There is no hooking method in OpenCart that you could do this with. The correct method to achieve this would be to use vQmod and add your code to the confirm() method as you've mentioned. That said, I'm not entirely sure what you are referring to with the license. You are free to modify the source code of OpenCart as you wish

Add comment when using Paypal checkout in magento

I want to know if there is any way to allow customers to add comments during checkout process when using Paypal checkout?.
EDIT: this comment will show up in the sales email and order.
I found some comments modules but seems to work only with the regular checkout process!.
Thanks in advance.
Adding that functionality with PayPal isn't an option, but you can add a comment after the order is placed on the thanks page.
You'll want to add a form with a text area to success.phtml, then follow the steps on the controller that it submits to. You'll probably want to submit to a custom module.
First, get the customer's last order:
$order = Mage::getModel('sales/order')->load(Mage::getSingleton('checkout/session')->getLastOrderId());
Next, take that order and update its comment.
$order->setCustomerNote($this->getRequest()->getParam('YOUR_COMMENT_FIELD_NAME'));
$order->save();
If you use AJAX you can return JSON stating the note has been saved (or a validation error occurred) directly from the controller and avoid the need for a view.
If you're unsure of how to go about creating a custom module I'd recommend starting here:
http://blog.baobaz.com/en/blog/developing-module-for-magento-tutorial-where-to-begin-part-1
The only change I'd recommend is not echoing your output (even if it is JSON directly from the controller), but instead using something like this:
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode(array('status'=>'success')));

Magento backend shipping selection

Heyhey,
I made a pretty kickass Magento 1.6 module to select a store and time to come pick stuff up at the shop, and it works fine in the front end. It doesn´t however appear in the backend, and the backend order creation system needs to have the same functionality.
How do I enable my module for backend order creation?
I'll supply any details needed!
Kind regards,
Alex
in the file:
/app/design/adminhtml/default/default/layout/sales.xml
around line 497 (on my version, which is Enterprise 1.10.0.1)
you should find
<adminhmtl_sales_order_create_index>
I strongly believe that has the information on what you want. Your module will need it's own layout xml file that references these areas to insert its own content. Then, you will need to hook into the order create event with an observer to run your own code to deal with the data. This may already be happening, as I'm not sure if the backend code creating the order is any different from the front end.
Hope this helps as a jumping off point.

Creating list from queries (Shopping cart like)

I need your help to get to the right direction on tackling this problem. I have a list of products from different vendors stored in the database. I wanted to be able to search through it and be able to add specific products and create a "Parts Order List". I was thinking of it like a shopping cart. The user should be able to browse/search through the product list and add certain products to the "cart" and then later view and print it. I'm stuck on what language to use. I'm familiar with PHP but from reading online this is mostly possible using CGI. What do you guys think? Any other Ideas? (Hope I make sense.)
Thanks in advance!!
If you're familiar with PHP why not use PHP then? Is there some reason you want to abandon what you know already to try something else?
EDIT
This beginner php tutorial on how to build a cart will teach you all you need to know about creating a similar system for your needs using sessions: http://v3.thewatchmakerproject.com/journal/276/building-a-simple-php-shopping-cart

Add to Cart API in Magento

I need to know how can I add products into cart using API. I have a list of products with details, I am trying to call the API from outside Magento. In which Magento's core class implements this function??
Thanks in Advance..
magento uses MVC and by looking at the cart link you can extract the path to the module, however
Mage_Checkout_CartController::addAction()
is the method you are looking for , remember that it is depending on session
In order to add to the cart you're going to have to implement your own API. That can be difficult because as Anton mentioned, it depends on session.
There was a project out there at one time, Mammoth Web Services, by some guys in the UK, but the project has gone silent.
If you have magento id's for your products this is fairly simple
http://yoursite.com/index.php/checkout/cart/add?product=product_id&qty=qty
http://www.magentocommerce.com/download/release_notes#Release%20Notes%20-%20Magento%201.4.2.0%20%28December%208,%202010%29
included in 1.4.2.0 apparently, though not on the official API documentation yet

Categories