Post by Brettster » Fri Sep 19, 2014 9:18 pm

Hi,

I'm new to customizing OpenCart. I've customized some parts of OpenCart before, but I'm trying to do something which should be very simple and I'm not having good luck with this one.

What I've done is add a form variable 'newsletter' to the /checkout page (I'm actually using QuickCheckout, so the page is at: route=quickcheckout/checkout ). That variable is ID/name='newsletter'. It is a checkbox, ticked by default, with a value of '1'.

What I want to do is when I click the [Continue] button on the bottom of the page (when the user is not logged in, as they will be a guest at this point), when I get to the next page, which is the page with the [Confirm] button on it, when they click that [Confirm] button on the next page (which is in the function /catalog/model/checkout/order.php at the bottom of the function) I want to be able to see if the user left that form variable ('newsletter') checked, or on, or if the user unchecked it. So, I would have a value of '1' if they left it checked, and no value (or unset) if they did not check it.

Can someone please tell me how to go about this? I've looked at template files, and just about everywhere, trying to see how to do this, but it escapes me at the moment?

TIA,
-Brett

Newbie

Posts

Joined
Mon Mar 03, 2014 2:14 pm

Post by dfumagalli » Wed Sep 24, 2014 5:21 pm

It's not the easiest of the tasks.

You have to create a list of every model, view, controller and language file used in any combination of possible user actions from the starting step to the last step where the modification should apply.

In every model you have to add a field (if it has to be stored in a database). If you don't have to store the setting you can sometimes just alter controllers and views (and languages!) to chain post it, other times you have to include it in the session and then it gets really funky, because the checkout code does all sorts of funny games with the session (including resetting some of the fields depending on the step).

If it looks like a mess, well, it is. That's why I am charging $69 for my vQMod that adds *1* field to addresses, registration forms, checkout etc. Dozens and dozens of modded locations.

Heavy OpenCart Customizations. Current project in progress: fleurworld.com


Active Member

Posts

Joined
Tue Aug 20, 2013 3:34 am

Post by PeteA » Thu Sep 25, 2014 12:25 am

Adding a field into QuickCheckout is more complicated than in the normal checkout. I've been doing exactly the same - currently added an invoice email and purchase order field into one step and some extra address fields too.

Are you happy creating vQmods or just hacking as I can give you a rough idea of where to do.

New member

Posts

Joined
Wed Jul 30, 2014 5:46 pm

Post by Brettster » Wed Oct 01, 2014 2:00 am

Hi Dfumagali,
In every model you have to add a field (if it has to be stored in a database). If you don't have to store the setting you can sometimes just alter controllers and views (and languages!) to chain post it, other times you have to include it in the session and then it gets really funky, because the checkout code does all sorts of funny games with the session (including resetting some of the fields depending on the step).
I cannot even read the form var from the very beginning, which is in Checkout/Order, I'm changing:
catalog/model/checkout/order.php

With this code, but it never gets set?
--

Code: Select all

$this->session->data['newsletter'] = $this->request->post['newsletter']; 
This is at the top of the code, in: public function addOrder($data) {

So, for starters WHERE/HOW can I get the variable that is set on the QuickCheckout Checkout Page (route=quickcheckout/checkout)?

Here's the code on that page:

Code: Select all

<input name="newsletter" value="1" id="newsletter" checked="checked" type="checkbox">
I need to read that, AFTER the user clicks [Continue] which keeps them on a quickcheckout/checkout page (but AFTER the Payment info is entered), so it's looking like this is in EACH individual payment method template file?? What code exactly would I put in there to PASS this 'newsletter' var on to the checkout page with the [Confirm] button, and then from there, on to the final checkout/success page?

Any help greatly appreciated - Thanks!
-Brett

Newbie

Posts

Joined
Mon Mar 03, 2014 2:14 pm

Post by Brettster » Wed Oct 01, 2014 2:04 am

Pete,

Please refer to my previous post, I just want to post one var, 'newsletter', from the quickcheckout/checkout page through to the final [Confirmed] page (order success), and be able to read that variable on the order success page.

I'm sure you have an easy solution to this, it can't be more then 2-3 modules that are changed, but I don't know where to start?
Are you happy creating vQmods or just hacking as I can give you a rough idea of where to do.
I prefer just hacking, I don't need to create a mod out of it, but just need to pass this one value so I can use it on the Order Success page - IF the user checked out as Guest, so I can run a snippet of my own code to add them to a newsletter.

I will PM you as well - TIA,
-Brett

Newbie

Posts

Joined
Mon Mar 03, 2014 2:14 pm
Who is online

Users browsing this forum: No registered users and 170 guests