Customization for Payment Gateway in opencart - php

So I am trying to set up a site on my localhost. I have selected 2 payment gateways from admin end
Online Payment (Free Shipping)
Cash On Delivery(Free Shipping/Flat COD Charge INR 50 )
Now I have customized all the rules for them. I only need one more rule.
I wish to have a functionality wherein I can enter some pincode/postcode values (through admin panel or maybe in some array in a javascript file or directly into the database, does not matter) of locations where second method is available)
Whenever someone presses continue before confirming order, the checkout form is validated so as to check from the form data if the value entered in post code matches the data (from any of the above methods) and if yes, only then they can continue or I wish to show an error message that
Following payment gateway is not available in your location
If you give me a hint on how to proceed with this, perhaps, I might be able to take it further. I am a bit or a starter in opencart so not much idea about how to proceed. I have sound knowledge of PHP, JQuery and Javascript although. So any and all help will be appreciated.

There are a few different extensions that already exist to do what you want - allow you to restrict shipping methods by various criteria. This one is my personal favorite: http://www.opencart.com/index.php?route=extension/extension/info&extension_id=1614

I managed it with JQuery for the time being. Edited the submit function in the cart.tpl file in catalog->view->theme->ancart (theme name) ->cart folder.
Used a plugin called "Zipcode COD" to enter zipcodes. Edited the response JQuery to hide and show payment options.
Lots of hard coding but does the trick. I will post the code if someone needs.

Related

Checkout step shipping after address - Prestashop 1.7

Task
My task is to re-map steps on checkout page in different groups but same order steps to fix UX and align better with expectation.
This sound as valid solution and won't change logic behind.
First page is ready: We have login and register as one step.
Second step is to confirm address and after that shipping method.
Third step I will use as payment select.
Last one will be summary.
Issue
Right now payment is with summary and shipping method is on separated step.
No documentation, just code and no hint how this can be achieved.
Very complex process of wiring and I just need frontend to be more elastic to my needs.
Is somewhere some clue how frontend can be modify in this area (steps on checkout)?
How this UI change can be properly done in code?
Screen of issue
[Step 3 - payment and summary is joined]
Screen of design that I try to achieve
[Screen of design - step 2] (shipping method is by default gray - only on project to showcase 2 steps together how they are join in one dot)
[Screen of design - step 3]
Any hint is welcome to resolve problem and it add as documentation to checkout step manipulation on frontend.
I don’t quite understand exactly what you want to achieve.
"Right now payment is with summary and shipping method is on separated
step."
is this an issue?
If you do not want to completely rethink checkout (like OPC modules), you need to follow the PrestShop checkout steps.
If you do not want to display something in the same step as currently have in PrestaShop (for example do you want to ask for phone number on Personal Information step, not on Address step), the best solution is to:
Modify the checkout step TPL files, and add the additional input field (for example add an phone_number input to Personal Information step)
Save the additional input to a JavaScript variable (even with setCookie)
Hide the input in its original step (hide the phone_number input from Address step)
Set the saved JS value to original(hidden) input
But if you can tell us exactly what modifications you would like, maybe we can help you more.

Use woocommerce with calculated quot from front end

I'm developing a website for a courier service, that has service quotation filling at the front end.
I did all form things working, a quotation will output variable with the cost of service in PHP.
After filling the form there will be checkout button, with that checkout button i need to save the details of the user, and that price to the woo commerce page to check-out/or fill further details. I searched throughout the google and got 1 solution to create a product with these values in front end. But its became very difficult to figuring out signing in, saving values, keep details in specific formate etc... for me as a beginner in PHP.
Can anyone help me with this?.
i just need woo commerce to make checkout with user entered details in the form.... .
EDIT & Updated :
Thanks for reply LoicTheAztec, I have gone through quick toure now
About code : I'm sending the values calculated in form to the page called buy-now using URL using javascript window.location.href=.
like http://example.com/buy-now?price=120&weight=80&location=000001
And also I'm able to fetch the value using
if (isset($wp_query->query_vars['pricef'])) in page template. (with StackOverflow help) and I'm checking user is logged in? using if(!is_user_logged_in()) and showing login form, After login also i can get the variables.
Now I need to create a transaction using this.
Saving data like a product or post and proceed for payment, I don't need to use woocommerce to do this but need some sort of idea to make it work.
Thank you.

Opencart Shipping Zip Code Check Before Order

I've an extension installed with opencart which helps customers to know whether their zip code is serviceable by logistics partner. But this is not mandatory. Still customers from these zip codes are ordering and it takes a lot of work for cancellation.
I found oc_zip_code table in mySQL is used. In the checkout page, customer enters Billing details and clicks continue button then Shipping details and continue button. On clicking this button, the system should check the entered zip code with the table and if there is a match it should continue else an error message should be displayed saying, "This zip code is non serviceable"
Or after entering shipping details, it should check automatically and give same error message or success.
Please help me to achieve this.
Shouldn't be too difficult to achieve but it requires understanding of OpenCart's controllers and models, some PHP knowledge and MySQL knowledge.
You need to extend your controller and model files.
In the controller/checkout/shipping_method.php I'd add a function named verifyZipCode($zipcode) and same function in the model files.
You'd then need to create a new table of valid zip codes in your database and have the controller call the model to query the database and return true or false if the zipcode exists.
Hope this helps!
Most payment modules have options to do this for you, for example Stripe is a very good module or PayMill - both have the option to select address and postcode checks before the order goes through.

Get notified on stock unavailability

I am trying to create a "Notify me" feature if the stock is unavailable.
On search on admin panel, I could find only that a user should sign up / log in to get notified about the stock availability.
But I just want to let the user (a guest) enter only his/her email address to get notified.
How should I do this?
Please give suggestions..
EDIT:
I have got this link, which gives me a way to start.
Till now what I did is added the following code in my template file which is creating a url for redirect (thinking to do it in ajax way, to stop page refreshing).
<?php
$actual_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
$base64 = strtr(base64_encode($actual_link), '+/=', '-_,');
$postUrl = "http://$_SERVER[HTTP_HOST]/efk/productalert/add/stock/product_id/" . $simpleProduct->getId() . "/uenc/". $base64;
?>
In the above code, efk is my project folder name.
After this, I have gone to productalert/add/stock controller method i.e stockAction() which is calling sign up / login form (I think so) using $model->save();.
How should I disable this save calling and add my own small overlay which holds a textbox to enter a email address?
Magento has "Notify me when product is back in stock" feature out of the box. It can be configured in admin panel: system / configuration / catalog / product alerts and product alerts run settings.
You're right, it works only for registred customers. To make it working for guest users some coding is required. I'd say you need to do the following steps:
Add email column to product_alert_stock table
Create new controller and action (believe me, it's better than you override existing one via config.xml) which extends Mage_ProductAlert_AddController::stockAction(). Your method will have to set guest's email to productalert/stock model.
Create subscription form and make sure it submits data to your new controller/action.
Update (override) Mage_ProductAlert_Model_Observer::_processStock() method to make it respect situations when "customer" has no ID but has email.
When you'll be testing, I suggest you to install SMTP Pro Email extension and mailcatcher to ease the testing process.
We have done this (http://www.alfresia.co.uk/sorrento-side-table.html/). Here we ended up creating a custom module as when we did this magento did not support any product alert system for the guest users (i do not know if this is supported now).
We first created a text box which would appear on product page where the product is out of stock. We were saving this info in one of our custom tables where we the schema was {id, email, product_sku, status} (status had three values Awaiting Stock, In Stock, and Already Notified).
We then wrote an observer which was hooked to cataloginventory_stock_item_save_after event, this helped us get the product sku which has been back in stock, and update all entries in our custom table with status In Stock and send a mail to the user.
This is how we did it, surely there will be a much cleaner way doing this.
You could have work with plugins. MagentoCommerce has loads of plugins/extensions which does the same
Free Version - http://www.magentocommerce.com/magento-connect/product-out-of-stock-subscription-1350.html
I too had similar requirement, and have installed 'http://www.magentocommerce.com/magento-connect/product-out-of-stock-subscription-1350.html' this plugin.
Well this plugin does the job, But they have override complete product view page template instead of simply adding a new block. By this your custom development on product view page development might get reflected on frontend.
Or else this plugin definitely does the job.
This http://www.magentocommerce.com/magento-connect/product-out-of-stock-subscription-1350.html plugin is really good but it breaks for configurable product types and it completely overrides the product controller which makes your system vulnerable to future upgrades. I think observers should be hooked to events where the product is back in stock and should update the users.

Magento - How to set Payment Information in backend for a custom Payment module

I have created a custom Payment module but I could only display the following information in the admin side of Magento
Type of Card
Card Number : xxxx-last 4 digits
Order was placed using USD
But how can I get other details just liek in case pf Paypal like,
Card Validation Status:
Address Validation Status:
Last Transaction ID:
etc. I am getting all these response from my custom payment gateway but I don't know what function to call or how to display it in the back-end for the store owner to see.
Can any one help me with this? Right now my payment module is doing authorize_capture as the payment action so I have Model/PaymentMethod.php which has function capture(Varien Object payment, amount) to deal with the logic. So can I set the Payment Information from there or do I need to create any other files?
Please let me know.
EDIT: I found partial answer to what I need doing.
http://nicholas.piasecki.name/blog/2009/10/add-avs-and-cvn-to-magentos-admin-screen-in-just-637-easy-steps/#comment-1043
But I am not able to override a default admin template file. This link tells to create a Block file which overrides Mage/Payment/Block/Info and set a template in there to be used.
But its not reading it. Can some one tell me the correct way to override an admin template file so that future upgrades don't overwrite it.
I hope some one must be familiar with this bit now.
it isn't taking the code from my overriden module Block file. The template file I need to over ride is app/design/adminhtml/default/default/template/payment/default/info.phtml. Using the link mentioned I have already overridden Mage/Payment/Block/Info and wrote my own code but am not able to set and point towards my template. Any Ideas?
Here is a good article by Alan Storm which will show you how to add settings to the backend:
http://alanstorm.com/custom_magento_system_configuration

Categories