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')));
Related
I wanted to run some code via PrestanShop when a specific button is pressed, before/after the designed action is happened.It's not alter the designed action, just is send some notification to an external system (notify the 3-rd party that we have a new sale and maybe with sales detalis: product, prices, etc)
To be more specific the action is finish a sale(or make an order) when click the related button.
I read something related (hooks and module) but maybe someone have the same issue then any help is appreciated.(even with no code, but good hints)
Maybe what hook is to be triggered here or some hints how to alter the code using PS-standards.
(light way and not just adding some php code to alter in the hard way the core)
Note: language on interface is romanian and the action is when a sale is post into the system (became an order, payments is not relevant/order_status).
Thank you,
Traian
You can use actionValidateOrder and make your call to your 3rd party in this function.
This hook is called here :
classes/PaymentModule.php line 716
I 'm trying to customize the order payment page (step 5),
it's the page shown just before the order confirmation.
The text to add in this page is a simple sentence that include the variables "order-ID" and the "total amount".
Example od sentence to add: "Your order number is: XXX and the amount is: YYY"
I guess that the first thing to do is to add the sentence and the 2 variables in the controller (probabily in the file "OrderController.php" or "OrderDetailController.php" Im not sure...)
Then the last step should be to add {$my_sentence} in the "order-payment.tpl" file?
I'm familiar with PHP, i just need to understand what files/function i need to edit.
Could someone please help me?
PS: My prestashop version is the 1.4, as payment module there is paypal pro and wire.
I stricly recommend that you modify anything using a module :
Create a simple module (look up simple module tutorials on the web)
Find exec() function in Hook.php, use error_log($hook_name) to find out which hooks are executed.
Regsiter the hook you selected in your module's install function. Then create a function public funtion hook{HOOK_NAME}($args){ error_log(print_r($args, 1)); }
You should find a hook that adds things to that page (adds display).
There is on problem though. I believe that the order is not formed until it is confirmed (in the enxt step). So the only thing you will probably have available in that page is Cart and Customer data.
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.
Having gained no response on the official Prestashop forum, I thought I would try turning to you guys, my first post. Thanks for reading.
I am building a site that sells personalized items, and it is essential that i can limit the characters entered into the customization fields for each item, a feature that is still sadly missing from Prestashop, so I am endeavoring to incorporate the feature myself.
Having tinkered about a bit, I have the front end working nicely, using maxlength to limit the characters allowed in the customization input field using a value read from the database in a new field 'max_chars' in the ps_customization_field (entering the values manually at the moment)
But now I have reached the limit of my knowledge and as much as i hunt around and tinker I cannot get the last bit done, so hopefully someone more knowledgeable than I can help.
Basically, when creating the customization fields in the back office, I need an extra input field that allows me to enter the max_chars for each customization, I then need this value to be written to the database in the max_chars field of ps_customization_field table.
TL:DR How do i create a new field in the back office product customization area and save the input to the db.
Kind regards,
Clive
Your question about "how to save input to my db" is too broad to be answered in a single answer. Look up how SQL queries and PDO work, as they may give you an idea on how to start.
Displaying your customization fields in the frontend can be done as following with Smarty:
{foreach $inputfields as $field}
<input type="{$field.type}" name="{$field.name}" maxlength="{$field.maxlength}">
{/foreach}
I think you should create a module for that. Simply make a module which add a tab to the admin product controller, and list all customized field created. Then, make a form with a simple id_customization => maxcharacter relationship.
The last thing you need is to create a hook in this module and add it in the product front controller where customizations are saved (inside initContent i think). This hook will do the validation and may cancel the process by throwing an error (a prestashop's error of course).
With that, you can add some extra validations for your fields, like a type validation, or anything else.
If you never made it, you should try this one : create a module
Here are some extra clues :
Hook for extra product tabs :
$this->registerHook('displayAdminProductsExtra')
Create the validation hook :
$this->registerHook('CFvalidation')
Handle it :
public function hookCFvalidation($param)
{
//Validate the customized values in the $_POST
//return formated errors if any or nothing if it's valid
}
Add it in the overrided product controller :
[...]
if (Tools::isSubmit('submitCustomizedDatas'))
{
$this->errors[] = Hook::exec('CFvalidation');
[...]
}
To display your inputs you need to override the method _displayLabelField in controllers/admin/AdminProdutsController.php.
To update the fields you need to override the method updateLabels in classes/Product.php.
How can I disable OnePage Checkout in OpenCart?
Version 1.5.x comes with it in the default template and I would rather not use it as we want to have step by step pages and not use Ajax (speed/page views and process serves our needs better) for our customers.
It is possible to remove the one-page setup, but you'll have to do a very good work on the template (the checkout folder contains all steps). You will need personalized controllers as well. The built-in checkout page uses jQuery and Ajax to gathering all the information necessary in only one page, to send everything together when the customer clicks "confirm".
Once you don't want to use ajax, you will have to send the information from one page to the next using post requests, putting then in hidden <input>'s and/or in $_SESSION variable. Anyway, you will have some problems with the countries and locations, since OpenCart retrieves then via ajax.
Actually, some time ago I've found some templates on ThemeForest and other sites that implemented what you want, but I don't know if they are available anymore.
I would actually recommend you use something like Uber Checkout which while its still a short checkout process, is better visually as you don't have the panels that are standard in 1.5.X. If you're wanting to completely rewrite it to work like the old checkout system, well in theory it's already there, you just need to rewrite the controllers for the various steps to output full pages rather than JSON and put in validations through each step to make sure previous steps have been completed