Jump to content

Recommended Posts

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!

Edited by katapofatico

Share this post


Link to post
Share on other sites

@@katapofatico,

 

You can check this example for a chopping_cart extension:

http://forums.oscommerce.com/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

Edited by raiwa

Share this post


Link to post
Share on other sites

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 :)

Share this post


Link to post
Share on other sites

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!

Share this post


Link to post
Share on other sites

 

 

[...]

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
Edited by katapofatico

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×