{"id":1614,"date":"2017-04-09T09:42:24","date_gmt":"2017-04-09T13:42:24","guid":{"rendered":"http:\/\/www.thatsoftwareguy.com\/blog\/?p=1614"},"modified":"2018-09-01T17:39:43","modified_gmt":"2018-09-01T21:39:43","slug":"upgrading-better-together-for-opencart-2-3-0-2","status":"publish","type":"post","link":"https:\/\/www.thatsoftwareguy.com\/blog\/2017\/04\/09\/upgrading-better-together-for-opencart-2-3-0-2\/","title":{"rendered":"Upgrading Better Together for OpenCart 2.3.0.2"},"content":{"rendered":"<p>Better Together is a BOGO discounting module I created for Zen Cart. \u00a0I have ported the logic to a few other carts (osCommerce, Prestashop, and OpenCart), and this post pertains to the OpenCart port.<\/p>\n<p>The first release of the\u00a0<a href=\"http:\/\/www.thatsoftwareguy.com\/opencart_better_together.html\">Better Together for OpenCart<\/a> module was for OpenCart 1.5. \u00a0Then I made a handful of tweaks for compatibility with version 2.0. \u00a0Now I knew I had to upgrade for 2.3 compatibility, but since the version 2 changes were pretty easy,\u00a0I honestly thought\u00a0upgrading for version 2.3.0.2 of OpenCart would be trivial. \u00a0I was wrong! \u00a0There were a few tricky things, and I&#8217;ll share them here in case other software developers are working on upgrading their pre-2.3 extensions.<\/p>\n<ol>\n<li>The file paths are different. \u00a0All file paths now include &#8220;extension&#8221; directories. \u00a0So instead of <code>catalog\/model\/total\/better_together.php<\/code>, the file path becomes <code>catalog\/model\/extension\/total\/better_together.php<\/code>.<\/li>\n<li>The inheritance hierarchy is different. \u00a0So instead of declaring your model class as ModelYourClass, it&#8217;s ModelExtensionYourClass, which extends Model.<\/li>\n<li>This is what really tripped me up. \u00a0Because the 2.3 base class overrides getters and setters, you have to be sure to declare all your class variables so that magic methods won&#8217;t be used to access them(*). \u00a0If you came out of PHP4, this is a bit of an adjustment, but there you are. \u00a0The positive thing is that it makes your code more self-documenting.<\/li>\n<\/ol>\n<p>(*) If you don&#8217;t do this, you&#8217;ll get the &#8220;Indirect modification of overloaded property has no effect&#8221; fatal error.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Better Together is a BOGO discounting module I created for Zen Cart. \u00a0I have ported the logic to a few other carts (osCommerce, Prestashop, and OpenCart), and this post pertains to the OpenCart port. The first release of the\u00a0Better Together for OpenCart module was for OpenCart 1.5. \u00a0Then I made a handful of tweaks for &hellip; <a href=\"https:\/\/www.thatsoftwareguy.com\/blog\/2017\/04\/09\/upgrading-better-together-for-opencart-2-3-0-2\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Upgrading Better Together for OpenCart 2.3.0.2<\/span><\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[83,58],"tags":[],"class_list":["post-1614","post","type-post","status-publish","format-standard","hentry","category-opencart","category-that-software-guy"],"_links":{"self":[{"href":"https:\/\/www.thatsoftwareguy.com\/blog\/wp-json\/wp\/v2\/posts\/1614","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.thatsoftwareguy.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.thatsoftwareguy.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.thatsoftwareguy.com\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.thatsoftwareguy.com\/blog\/wp-json\/wp\/v2\/comments?post=1614"}],"version-history":[{"count":3,"href":"https:\/\/www.thatsoftwareguy.com\/blog\/wp-json\/wp\/v2\/posts\/1614\/revisions"}],"predecessor-version":[{"id":1617,"href":"https:\/\/www.thatsoftwareguy.com\/blog\/wp-json\/wp\/v2\/posts\/1614\/revisions\/1617"}],"wp:attachment":[{"href":"https:\/\/www.thatsoftwareguy.com\/blog\/wp-json\/wp\/v2\/media?parent=1614"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.thatsoftwareguy.com\/blog\/wp-json\/wp\/v2\/categories?post=1614"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.thatsoftwareguy.com\/blog\/wp-json\/wp\/v2\/tags?post=1614"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}