Can anyone tell me how can we extend Base class

Help for integrating the Laravel package
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
skydev
Posts: 18
Joined: 01 Jul 2021, 10:24

Can anyone tell me how can we extend Base class

Post by skydev » 01 Mar 2022, 07:40

Hi,

Can anyone tell us how can we extend base class

FYI: We are using aimeos 2020.10

basically we want to modify

Code: Select all

getTaxRates
method available at

Code: Select all

Aimeos\Client\Html\Common\Client\Summary\Base class 
We try to extend it with Decorator but unable to do can

Can anyone help below is client config code

Code: Select all

'html' => [
        "common"=>[
          "client"=>[
              "summary"=>[
                  "decorators"=>[
                      "local"=>class_basename(\Aimeos\Client\Html\Common\Client\Summary\Decorator\SummaryDecorator::class)
                  ]
              ]
          ]
        ],

User avatar
aimeos
Administrator
Posts: 7926
Joined: 01 Jan 1970, 00:00

Re: Can anyone tell me how can we extend Base class

Post by aimeos » 02 Mar 2022, 07:28

In OOP, it's not possible to replace base classes and as the methods in the base class are protected, you can't use decorators either (they require public methods). The only way to replace these methods is to overwrite the classes that extend from it but this is thedios and you have to duplicate the code.

In dev-master, we've move that code to the order base item which is much easier to replace with an own implementation:
https://github.com/aimeos/aimeos-core/b ... #L784-L848
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

skydev
Posts: 18
Joined: 01 Jul 2021, 10:24

Re: Can anyone tell me how can we extend Base class

Post by skydev » 02 Mar 2022, 07:44

@aimeos thanx for this info

Is there any other way through which we can extend

Code: Select all

getTaxRates 
method extended ?

User avatar
aimeos
Administrator
Posts: 7926
Joined: 01 Jan 1970, 00:00

Re: Can anyone tell me how can we extend Base class

Post by aimeos » 02 Mar 2022, 08:00

Like said, only by extending from the classes that extend from the base class themselves and configuring these classes to be used instead of the original ones.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

skydev
Posts: 18
Joined: 01 Jul 2021, 10:24

Re: Can anyone tell me how can we extend Base class

Post by skydev » 02 Mar 2022, 09:10

Okay @aimeos

We want to tax should exclude discount amount for example

we have created a plugin that says buy 10 pay for 8 but want to include the tax on 10 product (right now it apply on 8 product total)

can you please give us any idea for this

User avatar
aimeos
Administrator
Posts: 7926
Joined: 01 Jan 1970, 00:00

Re: Can anyone tell me how can we extend Base class

Post by aimeos » 03 Mar 2022, 09:20

The easiest way might be to create a decorator attached to the basket and checkout components which overwrites the "summaryNamedTaxes" key assigned to the template by the components with your own computed value.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply