katapofatico Posted November 18, 2015 Share Posted November 18, 2015 Hello, I'm developing extensions to gburton/Responsive-osCommerce (thanks @@burt) and I want to extend the order class interface with, but I don't know how. Any tip about it? Modifying core order.php This is what I avoid to do. Modifying all ocurrences of require(DIR_WS_CLASSES . 'order.php') to require(DIR_MY_CLASSES . 'order.php') in 13 files... is there any way less intrusive? Thanks a lot! Link to comment Share on other sites More sharing options...
♥raiwa Posted November 18, 2015 Share Posted November 18, 2015 @@katapofatico, You can check this example for a chopping_cart extension: http://www.oscommerce.com/forums/topic/408481-sppc-lite/?p=1734997 and if you download the following add-on you can find a more simple example for a currency extension: http://addons.oscommerce.com/info/9365 the class extension is included and called in the store module: includes/modules/store/st_tax_below_price.php $currencies = new currencies_mod(); and the extension class at the end: if (class_exists('currencies')) { class currencies_mod extends currencies { // add tax below price mod public function format($number, $calculate_currency_value = true, $currency_type = '', $currency_value = '', $products_tax = '', $show_tax_info = true) { ...................... hope this helps regards Rainer About Me: http://www.oscommerce.com/forums/user/249059-raiwa/ Need help? How To Get The Help You Need Is your version of osC up to date? You'll find the latest osC community version CE Phoenix here. Public Phoenix Change Log Cheat Set on Google Sheets Link to comment Share on other sites More sharing options...
katapofatico Posted November 18, 2015 Author Share Posted November 18, 2015 Thanks a lot for you quick answer,@@raiwa :thumbsup: I had seen your currencies.php customization, but these case it's too much simple comparing with order.php: It works well because you have to replace the global instance in $currencies. Consider if you have to to the same on admin, where there are requires and instances creations after require application_top.php, for example in orders.php: require('includes/application_top.php'); require(DIR_WS_CLASSES . 'currencies.php'); $currencies = new currencies(); This is my case... more similar to your shoppingCartMod class. Your example leads me to modify 13 core files with order class instantiation: require(DIR_WS_CLASSES . 'order.php'); $order = new order; // my customization start require(DIR_MY_CLASSES . 'MyOrder.php'); $order = new MyOrder(); // my customization end I was looking for a less intrusive way, but perhaps there is not any other... :( If you have any comments I'll be grateful. In any case, thanks for guide me to the best code! Disculpa mi inglés :) Link to comment Share on other sites More sharing options...
piernas Posted November 18, 2015 Share Posted November 18, 2015 I've faced the same problem with orders class and did not find a good solution, so I ended up modifying the class itself. Will follow this topic in the hope someone sheds light on the problem! Link to comment Share on other sites More sharing options...
katapofatico Posted November 19, 2015 Author Share Posted November 19, 2015 [...] require(DIR_WS_CLASSES . 'order.php'); $order = new order; // my customization start require(DIR_MY_CLASSES . 'MyOrder.php'); $order = new MyOrder(); // my customization end [...] Update: My code above was inspired on @@raiwa your shoppingCartMod class, that manages a global variable $cart. In order class insntances case, it's better (more versatile) to pass the original $order as constructor parameter: require(DIR_WS_CLASSES . 'order.php'); $order = new order; // my customization start require(DIR_MY_CLASSES . 'MyOrder.php'); $order = new MyOrder($order); // my customization end Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.