Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3211520
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T14:44:32+00:00 2026-05-17T14:44:32+00:00

I have an e-shop with multiple product types. And i would have thought of

  • 0

I have an e-shop with multiple product types. And i would have thought of the following structure

Cart_Item
-- Cart_Product
-- Cart_Download

Order_Item extends Cart_Item
-- Order_Product
-- Order_Download

The problem is that i want to have Order_Product extend Order_Item and Cart_Product.
This is because it needs method generic to Order_Item ( get price from Order not from product ) but also methods from Cart_Product ( shipping calculations )

I know that php doesn’t support multiple inheritance, i was wandering what is the cleanest way to emulate this.

Right now i have Order_Product extend Cart_Product duplicate code from Order_Item in Order_Product an Order_Download.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T14:44:33+00:00Added an answer on May 17, 2026 at 2:44 pm

    Either use Interfaces and implement the methods manually or via Strategies. Or use Composition instead of Inheritance, meaning you let the Order_Product have a Order_Item and a Cart_Product.

    On a sidenote: You could also consider making "shipping calculations" into it’s own Service class that you can pass appropriate Product instances to.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my shop (as I expect it is in most), you have multiple releases
I have an association, Shop habtm Products Product habtm Shops Shop belongs_to Merchant For
A have two models, shop and product, linked via has_many :through. In the shop
I have two tables, products and category. A product can be in multiple categories.
I have the following situation in my cube: Shop A uses calendar Cal1. Their
I have a shop system that integrates PayPal in the usual way, i.e. the
I have a Magento shop and I want to place a banner after every
We have a Magento Shop and the shipping settings are already set and everything
I am designing a Point-Of-Sale system for a small shop. The shop just have
I have to populate a shop's images and been provided with folders of images

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.