Post by JustinCase » Thu Aug 18, 2011 12:39 am

Hi,

I've been programming since 1984 and have felt pretty comfortable in almost every new language I've tackled over the years. I've written some incredibly complex software for the stock market industry so I wouldn't say that I'm a beginner programmer. Most of my experience over the last ten years has been in Microsoft ASP pages, my current task to add a payment into this website--if it were done in ASP pages--would have probably taken me no more than about three hours of work.

That said, I've already spent at least five full days of pulling my hair out trying to understand what is going on with OpenCart. I wouldn't say that any of this is "easy", having just read now all the glowing information about the benefits of MVC+L. So far, I'm mostly impressed by the obsfucation that's been added by this. For example, I was decyphering one page's output and what would normally be static text was coming from 1) the language file, 2) the controller/model code from the mysql db and 3) the template itself. You suggest that this code should only come from the language file itself. And yes, I know why you might put some text in the database--I've designed countless systems.

I need to add a payment method. It's really that simple. In fact, why on earth wouldn't you include a standard credit card processing method for people who have a brick-and-mortar store and have a POS system? You could just store the credit card information. But instead you only offer the ability to sign up with yet another middle man who wants a cut of the transactions. :(

So here I am, coding up another payment method. This should be simplicity itself. I should be able to duplicate one of the existing payment methods, change the names, change the variable names themselves and "install" it in the admin section. I've done this but now I'm completely flummoxed by the lack of documentation about HOW the pages submit data from a form back to itself.

In ASP page terms:
  1. A form has an ACTION attribute which determines where the POST'd data goes
  2. The recieving *ASP* page has server-side functionality at the top of that page that fetches the arriving variables
  3. At this point you might have local-scope variables or session-scope variables or even application-scope variables
  4. At this point you're free to use code to write them to the database if you wish
  5. The ASP page then has static HTML and inline dynamic data from those various types of variables
That, to me, is easy and understandable. If I wanted to separate the MVC+L I'd do that by separating things in server-side includes, mostly. And yet, the work would be done.

--------------------------

So here I am with this OpenCart.
  • In the shipping/payment areas it doesn't look like the Comment form field is being email'd or stored in the Order or Order_History tables at all. Why ask the information if it's not being stored? I actually need this data and have been fruitlessly trying to get it stored in the order_history table, for example.
  • I've searched throughout the many pages and I see references to: $data['comment'], $this->session->data['comment'], $comment, nl2br($this->session->data['comment']), there's a comment field in order_history. I've attempted to use any of these in an attempt to store the data and they keep showing up empty.
  • I'm interested in a form submission from the "checkout/payment" page to the "checkout/confirm" page. In theory, somewhere in the controller I'm going to store to variables those form elements that I've submitted. In theory, somewhere upon the "checkout/confirm" submission it goes... SOMEWHERE to server-side code. Where is this?
Guys, this isn't simple. You have multiple layers/shims of controllers and languages and views per page. *When* each gets called seems to be significant. The "checkout/confirm" page in theory has a server-side before rendering aspect to it and also a server-side after form submission aspect to it. So what/where is that anyway?

To make matters worse you sometimes have injected AJAX code into the button submissions. The ACTION aspect of the form submission is also obsfucated so much that it's difficult to tell where the page is going.

In a nutshell then my question is: When the customer clicks the final CONFIRM button on the "checkout/confirm" page, where does it go? What server-side code processes and writes the data? Why isn't COMMENT written? How do I know that my stored data from the "checkout/payment" page is preserved somehow?

My suspicion is that all these layers are each attempting to save the comment field in their own way and one is eventually overwriting my attempts to save this data. I'm weary of this project.

What is the difference and scope of these variables?
$data['comment']
$this->session->data['comment']
$comment
nl2br($this->session->data['comment'])

When is the order written? (Is it after "checkout/confirm" itself is submitted back to the server?) In theory, if I know that the order has been written to the database then I can make the SQL call to update the order_history table myself.

Seriously guys, the documentation needs a diagram of what happens during a form submission back to itself. There is nothing easy about the end of the point-of-sale process since it includes layers of modules in a stack: product, shipping, address, payment, coupon. It's not clear when a particular CMV set is being used to render a page itself and whether/not it processes the submitted form itself.

You have methods like confirm() in some of the payment extensions. But most of these extensions are dedicated to exporting the data to someone else's website in EDI fashion. All my attempts to keep the data here and store it are flummoxed by what is, to me, an overly complicated system.

Sorry for the bad review of OpenCart but I just felt you ought to know what it's like to use it as a long-time developer.

I imagine that the first question you'll ask is what version of OpenCart I have. Unfortunately I have inherited all this mess from an outsourced project from India. There doesn't appear to be version information written anywhere throughout. I actually had to google some of the error messages to deduce that it is OpenCart. Suggestion: Couldn't you just write the OpenCart version information into the META tags in the header like other developers do?

Newbie

Posts

Joined
Wed Aug 17, 2011 11:38 pm

Post by Qphoria » Thu Aug 18, 2011 12:51 am

Take a look at this... its high-level but may fill in some gaps
http://forum.opencart.com/viewtopic.php?f=20&t=4113

From there, I am going to be doing a screencast of things like this in the upcoming week or so that will better clarify things.

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by JustinCase » Thu Aug 18, 2011 5:26 am

Qphoria wrote:Take a look at this... its high-level but may fill in some gaps
http://forum.opencart.com/viewtopic.php?f=20&t=4113
Been there, read that. Really, I spent a few hours this morning reading the existing documentation.

To make a long story short, I just finished this. Here's the code from the confirm() method in /catalog/controller/payment/mypayment.php now:

Code: Select all

	public function confirm() {
		$this->language->load('payment/creditcard');
		$this->load->model('checkout/order');
		$comment = $this->session->data['comment'];
		$this->model_checkout_order->confirm($this->session->data['order_id'], $this->config->get('creditcard_order_status_id'), $comment);
	}
Seems like the comment data is floating around in the session data array, not available as a local variable. The create() function in /catalog/model/checkout/order.php doesn't apparently store the comment value into the order table, however confirm() does.

-----------------------

What I find as odd behavior is that it's apparently /catalog/controller/payment/mypayment.php's duty to tell the database to write the record as an order and not code in something like /catalog/controller/checkout/confirm.php or /catalog/controller/checkout/success.php or similar.
Qphoria wrote:From there, I am going to be doing a screencast of things like this in the upcoming week or so that will better clarify things.
Thanks. I have literally ten handwritten/short-hand sheets of notes on the various pieces of this huge puzzle in front of me here on my desk. To gain some insight into this I printed out /index.php then made notes along the way, visiting each of the included files (discovering what they do and then making additional notes).

I pieced this solution together after reading many of the posts in obscure/unrelated places on this forum and then doing an all-files search for that confirm() function.

Newbie

Posts

Joined
Wed Aug 17, 2011 11:38 pm

Post by Xsecrets » Thu Aug 18, 2011 5:29 am

JustinCase wrote:Hi,

I've been programming since 1984 and have felt pretty comfortable in almost every new language I've tackled over the years. I've written some incredibly complex software for the stock market industry so I wouldn't say that I'm a beginner programmer. Most of my experience over the last ten years has been in Microsoft ASP pages, my current task to add a payment into this website--if it were done in ASP pages--would have probably taken me no more than about three hours of work.

That said, I've already spent at least five full days of pulling my hair out trying to understand what is going on with OpenCart. I wouldn't say that any of this is "easy", having just read now all the glowing information about the benefits of MVC+L. So far, I'm mostly impressed by the obsfucation that's been added by this. For example, I was decyphering one page's output and what would normally be static text was coming from 1) the language file, 2) the controller/model code from the mysql db and 3) the template itself. You suggest that this code should only come from the language file itself. And yes, I know why you might put some text in the database--I've designed countless systems.

I need to add a payment method. It's really that simple. In fact, why on earth wouldn't you include a standard credit card processing method for people who have a brick-and-mortar store and have a POS system? You could just store the credit card information. But instead you only offer the ability to sign up with yet another middle man who wants a cut of the transactions. :(
I don't see how MVC is all that complicated it's very common place nowdays. If I'm not mistaken even many asp frameworks utilize it. Besides that if all you need is an offline credit card module you should have searched Q has a commercial one available at a very reasonable price I can't imagine that the cost would more than have been offset even if you did only take 3 hours to write it. Unless you are charging $5/hour.
So here I am, coding up another payment method. This should be simplicity itself. I should be able to duplicate one of the existing payment methods, change the names, change the variable names themselves and "install" it in the admin section. I've done this but now I'm completely flummoxed by the lack of documentation about HOW the pages submit data from a form back to itself.
It's not that hard to grasp. they basically simply take the post data and throw it directly into the database. if it's an array they serialize it first and set the serialize field to 1.
In ASP page terms:
  1. A form has an ACTION attribute which determines where the POST'd data goes
  2. The recieving *ASP* page has server-side functionality at the top of that page that fetches the arriving variables
  3. At this point you might have local-scope variables or session-scope variables or even application-scope variables
  4. At this point you're free to use code to write them to the database if you wish
  5. The ASP page then has static HTML and inline dynamic data from those various types of variables
the same can be done in php it's just that for the modules all the data is settings and generally doesn't need to be messed with, so it's just thrown directly into the database instead of creating tons of redundant code setting all the variables then putting them into the database.
That, to me, is easy and understandable. If I wanted to separate the MVC+L I'd do that by separating things in server-side includes, mostly. And yet, the work would be done.

--------------------------

So here I am with this OpenCart.
  • In the shipping/payment areas it doesn't look like the Comment form field is being email'd or stored in the Order or Order_History tables at all. Why ask the information if it's not being stored? I actually need this data and have been fruitlessly trying to get it stored in the order_history table, for example.
  • I've searched throughout the many pages and I see references to: $data['comment'], $this->session->data['comment'], $comment, nl2br($this->session->data['comment']), there's a comment field in order_history. I've attempted to use any of these in an attempt to store the data and they keep showing up empty.
  • I'm interested in a form submission from the "checkout/payment" page to the "checkout/confirm" page. In theory, somewhere in the controller I'm going to store to variables those form elements that I've submitted. In theory, somewhere upon the "checkout/confirm" submission it goes... SOMEWHERE to server-side code. Where is this?
the comments do indeed get stored to the database upon order creation. Why would it be there if it didn't, and how did you think the admin magically knew what it was after an order was completed? It's stored in a session till the order is created then it's added to the database with the order.
Guys, this isn't simple. You have multiple layers/shims of controllers and languages and views per page. *When* each gets called seems to be significant. The "checkout/confirm" page in theory has a server-side before rendering aspect to it and also a server-side after form submission aspect to it. So what/where is that anyway?
what can you not submit a form to the same page in asp?
To make matters worse you sometimes have injected AJAX code into the button submissions. The ACTION aspect of the form submission is also obsfucated so much that it's difficult to tell where the page is going.
can't really argue too much here I have no idea why Daniel feels the need to have every button activated by javascript, and that has been complicated quite a bit in 1.5 with the onepage checkout you have to dig through all the javascript at the bottom of the checkout.tpl file to figure out what each button click does under different circumstances, but much of that complication is required to have a one page checkout.
In a nutshell then my question is: When the customer clicks the final CONFIRM button on the "checkout/confirm" page, where does it go? What server-side code processes and writes the data? Why isn't COMMENT written? How do I know that my stored data from the "checkout/payment" page is preserved somehow?

My suspicion is that all these layers are each attempting to save the comment field in their own way and one is eventually overwriting my attempts to save this data. I'm weary of this project.

What is the difference and scope of these variables?
$data['comment']
$this->session->data['comment']
$comment
nl2br($this->session->data['comment'])
$data['comment] is a local scope variable in some file.
$this->session->data['comment'] is a session variable.
$comment is a local variable in some file.
nl2br($this->session->data['comment']) is the session variable run through the nl2br php function which adds <br> for line breaks.
When is the order written? (Is it after "checkout/confirm" itself is submitted back to the server?) In theory, if I know that the order has been written to the database then I can make the SQL call to update the order_history table myself.
the order is written when the checkout confirm is loaded, then updated with an order status when the payment process is completed.
Seriously guys, the documentation needs a diagram of what happens during a form submission back to itself. There is nothing easy about the end of the point-of-sale process since it includes layers of modules in a stack: product, shipping, address, payment, coupon. It's not clear when a particular CMV set is being used to render a page itself and whether/not it processes the submitted form itself.
well you are dealing with the most complicated portion of the system, an most of it is by necessity. each time you click one of the buttons it uses ajax to send that data back to the next controller and return the next step.
You have methods like confirm() in some of the payment extensions. But most of these extensions are dedicated to exporting the data to someone else's website in EDI fashion. All my attempts to keep the data here and store it are flummoxed by what is, to me, an overly complicated system.
the confirm function is used to confirm the order and apply an order status to it, otherwise it stays as a temp/missing order.
Sorry for the bad review of OpenCart but I just felt you ought to know what it's like to use it as a long-time developer.

I imagine that the first question you'll ask is what version of OpenCart I have. Unfortunately I have inherited all this mess from an outsourced project from India. There doesn't appear to be version information written anywhere throughout. I actually had to google some of the error messages to deduce that it is OpenCart. Suggestion: Couldn't you just write the OpenCart version information into the META tags in the header like other developers do?
well from the way you are talking I'm guessing it's 1.5+ because you are talking about all the ajax stuff which did not exist in the older 1.4.x versions. If there are no version numbers it's because the developer who did it removed them. Opencart does have version number as the first variable in the index.php and admin/index.php by default.

OpenCart commercial mods and development http://spotonsolutions.net
Layered Navigation
Shipment Tracking
Vehicle Year/Make/Model Filter


Guru Member

Posts

Joined
Sun Oct 25, 2009 3:51 am
Location - FL US

Post by Xsecrets » Thu Aug 18, 2011 5:34 am

JustinCase wrote: What I find as odd behavior is that it's apparently /catalog/controller/payment/mypayment.php's duty to tell the database to write the record as an order and not code in something like /catalog/controller/checkout/confirm.php or /catalog/controller/checkout/success.php or similar.
actually no it's not the payment modules responsibility to tell the system to write the order. It is it's responsibility to tell it to update the order with an order status so that it is marked as a complete order signifying that it passed the processing check.

so basically when checkout_confirm loads it saves the order only without any order status info, then when the confirm button is pressed the payment module does it's thing either through api or by sending you to another site, and when it has approved the order it adds order status to it to make it a real order. If for instance you leave and goto paypal and do not pay or return then it just leaves that "missing order" out there with no status not completed. It does this because most processing systems require you to sent your order_id along with the order information to approve the order then you know which order id to add status to when you get approval along with the order id back from the processor.

OpenCart commercial mods and development http://spotonsolutions.net
Layered Navigation
Shipment Tracking
Vehicle Year/Make/Model Filter


Guru Member

Posts

Joined
Sun Oct 25, 2009 3:51 am
Location - FL US

Post by JustinCase » Tue Aug 23, 2011 2:19 am

Xsecrets wrote:I don't see how MVC is all that complicated it's very common place nowdays. If I'm not mistaken even many asp frameworks utilize it. Besides that if all you need is an offline credit card module you should have searched Q has a commercial one available at a very reasonable price I can't imagine that the cost would more than have been offset even if you did only take 3 hours to write it. Unless you are charging $5/hour.
The concept of MVC isn't complicated if the designers are faithful to the methodology and don't add Ajax workarounds for form submissions.

Today's five-hour programming task (which would have taken about 30 minutes in the ASP world) involved simply trying to add a single checkbox and accompanying SQL code to the order update page. Why did it take so long? It took so long because it was almost as if the receiving page wasn't getting my new checkbox's data.

And yes, that was indeed the case because /admin/view/template/sale/order.tpl has a bunch of Ajax code that--upon form submission--completely ignores the standard HTML form behavior and does its own thing. Why didn't I notice this when I went in to add the checkbox? There's no sourcecode formatting in the TPL files themselves since they likely have the UNIX-style hard returns in them. Without any sourcecode formatting of whitespace then everything's just a mess and you're unlikely to see a block of Ajax scripting at the bottom.
Xsecrets wrote:what can you not submit a form to the same page in asp?
Yes, it's the expected way of doing it if you've been programming ASP for more than a few months, submitting the page back to itself.
Xsecrets wrote:can't really argue too much here I have no idea why Daniel feels the need to have every button activated by javascript, and that has been complicated quite a bit in 1.5 with the onepage checkout you have to dig through all the javascript at the bottom of the checkout.tpl file to figure out what each button click does under different circumstances, but much of that complication is required to have a one page checkout.
Granted, there's some cool-looking Ajax submission going on. Things look professional when you submit something back to the site and it just auto-expands. But why not then make ALL form submissions and navigation use this? Then the developer doesn't have to laboriously dig through every scrap of code to find out why form elements aren't getting posted.
Xsecrets wrote:well you are dealing with the most complicated portion of the system, an most of it is by necessity. each time you click one of the buttons it uses ajax to send that data back to the next controller and return the next step.
...hence the need for some documentation about the various ways that navigation happens within OpenCart. Having just gone through this with a fine-tooth comb it looks like there are default (non-Ajax) navigation-related pieces that are being ignored when the designed has now decided to drop in some Ajax. The net effect is that the person like myself sees the standard navigation, thinks that it's what is supposed to happen, and then is surprised when some other behavior is happening instead.
Xsecrets wrote:Opencart does have version number as the first variable in the index.php and admin/index.php by default.
Looks like it's 1.4.8 then.

I guess the short version of my rant is: don't suggest that all this is EASY given the way it was implemented. If you subtracted all the Ajax and JavaScript submission eccentricities out of OpenCart then you could try to claim that all this is straightforward.

Newbie

Posts

Joined
Wed Aug 17, 2011 11:38 pm

Post by Qphoria » Tue Aug 23, 2011 3:20 am

It is true.. the coolness of ajax is hampered by the increased complexity understanding all the bits. And debugging gets to be a lot harder as well. Tho what if it was Ajax on ASP? would it differ that much? Is the problem php or the problem the way ajax was used?

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by Xsecrets » Tue Aug 23, 2011 6:23 am

JustinCase wrote:Why didn't I notice this when I went in to add the checkbox? There's no sourcecode formatting in the TPL files themselves since they likely have the UNIX-style hard returns in them. Without any sourcecode formatting of whitespace then everything's just a mess and you're unlikely to see a block of Ajax scripting at the bottom.
not sure what you are using, but I've used about 5 different IDE's and every on has seen the source code formatting perfectly well and yes the code is very well formatted, it's not our fault if you are trying to use notepad or some other ridiculous tool to program in.
Xsecrets wrote:well you are dealing with the most complicated portion of the system, an most of it is by necessity. each time you click one of the buttons it uses ajax to send that data back to the next controller and return the next step.
...hence the need for some documentation about the various ways that navigation happens within OpenCart. Having just gone through this with a fine-tooth comb it looks like there are default (non-Ajax) navigation-related pieces that are being ignored when the designed has now decided to drop in some Ajax. The net effect is that the person like myself sees the standard navigation, thinks that it's what is supposed to happen, and then is surprised when some other behavior is happening instead.
Well I have to agree the ajax onepage could have been handled better. It really was just kind of bolted onto the existing multipage. And honestly there really is no reason he could not have simply used complete form submission instead of manually picking out each input it's very simple to tell jquery to just post form blah.
Xsecrets wrote:Opencart does have version number as the first variable in the index.php and admin/index.php by default.
Looks like it's 1.4.8 then.
that doesn't sound right at all 1.4.8 did not have any ajax in the checkout other than one very small piece at the very end on the submission. All of the ajax was added in 1.5.0
I guess the short version of my rant is: don't suggest that all this is EASY given the way it was implemented. If you subtracted all the Ajax and JavaScript submission eccentricities out of OpenCart then you could try to claim that all this is straightforward.
Well lets see you messed with what 5% of the codebase, and that just so happens to be the only 5% that is complex, and 99% of people will never mess with it, so yeah I think it's still fair to say that opencart coding is easy to understand.

OpenCart commercial mods and development http://spotonsolutions.net
Layered Navigation
Shipment Tracking
Vehicle Year/Make/Model Filter


Guru Member

Posts

Joined
Sun Oct 25, 2009 3:51 am
Location - FL US

Post by AdieB » Wed Feb 05, 2020 8:37 pm

If I may add to the discussion. I believe that by simply adding comments to some of the complex areas, e.g. to the checkout.tpl jquery areas giving a simple explanation would go a long way to assisting any developer.
I am currently stuck here trying to decipher and it is extremely frustrating for a framework that has many good properties otherwise.
I do understand that it is opensource and nobody is obliged to assist, but it will help with some of the negativity.

New member

Posts

Joined
Mon May 19, 2014 9:01 pm

Post by IP_CAM » Wed Feb 05, 2020 10:20 pm

I do understand that it is opensource and nobody is obliged to assist...
Well, only the Code is OpenSource, the Project itself only serve's commercial Purposes,
for most everybody involved. :laugh: So, what do you expect, from a software, only built
to create income ???
Ernie

My Github OC Site: https://github.com/IP-CAM
5'600 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by AdieB » Thu Feb 06, 2020 12:27 am

Sure, bit I guess anybody who has dived in this deep is most likely a developer and not just a hobbyist. So comments could be added as a professional courtesy if one has already done the work of deciphering the code - or not... ;) :laugh: :laugh:

New member

Posts

Joined
Mon May 19, 2014 9:01 pm

Post by IP_CAM » Thu Feb 06, 2020 1:29 pm

Well, it's easy, to basically understand, how the OC Framework functions. :D
It's like a Car, with a System-, an Engine-, a Drive- and a Body- Section, just
like OpenCart has a System-, a Controller-, a Model- and a Theme Section.
But how all that works in detail, most Car Owners probably won't know about.

And most OC Users don't need to know much technical Stuff either, like me,
they just have to find out, if something similar exists, if they plan to change
things, and then 'compare', just like a Mechanic, to eventually 'match' some
piece of Code with existing Things. ;) ;D

It's a major reason, why it took me so long, to make my thing work as planned,
confronted with the unparalelled choice of OC additions, and the huge written
wisdom about. :crazy:

If one would not be a Hobbyist, one would just be Nuts, to waste so much time,
instead of creating some cash, by doing, what most everybody would do. :drunk:

For a Hobbyist, it's all about finding out, by trying, what makes the difference
between him, and one, how knows ... 8) It's much more fun too, if it finally works.
Comparably again with a Mechanic and a Hobby Tuner, the one's works for money,
and the others, to make 'em feel good ... :D

Ernie

My Github OC Site: https://github.com/IP-CAM
5'600 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by AdieB » Thu Feb 06, 2020 2:37 pm

In the same analogy of the mechanic, it is like a mechanic trying to set the timing of a car without a manual. He knows there are many other mechanics who have managed to do it before, but generally won't assist with the timing settings unless they are paid for them. Sure, they spent the time reverse-engineering how to set the timing, so they are entitled to receive something for their knowledge, but is this not against the spirit of what opensource is about. Maybe he can reciprocate in the future by passing some information back to them. OK I am going to put my crash helmet on now while I wait for the repercussions of my comments... :joker: :joker: :joker:

New member

Posts

Joined
Mon May 19, 2014 9:01 pm
Who is online

Users browsing this forum: No registered users and 8 guests