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 8989921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:22:49+00:00 2026-06-15T22:22:49+00:00

I successfully created simple web app with cart. Now i need to implement some

  • 0

I successfully created simple web app with cart.

Now i need to implement some special offers.

Example 1: if customer added 2 pieces of some product – second piece should cost 30% less.

Example 2: if customer add product_1 and product_2 – then I have to add product 3 for free.

There is no problem with implementing bussiness logic itself.

The problem is, that I have no product detailed information in Codeigniter Cart.

There are id, name, qty, price, subtotal and options fields in item object/array.

To recalculate prices without querying database on every cart change I need some additional fields, something like group/category, which tell me what special offer applies to that product.

Additionally – i need to store base price somewhere, because when customer remove some product from cart – i will need to put old prices there.

Where I should put that additional informations?

options field is already used…

I don’t want to query database on every cart update (i want my web application to be very fast and I want minimum server load).

Shall i expect some problems with these rowid‘s, when i change price of some cart item?

Im asking about this, because cart unique ‘rowid’ is an md5 checksum of item id and options array. My application will use diffrent prices for same product with same options (one piece normal price, another 70% price for example).

  • 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-06-15T22:22:50+00:00Added an answer on June 15, 2026 at 10:22 pm

    Codeigniter cart will get you started, but for any kind of customizing, i recommend doing your own cart, will be much easier. Remember all a cart has to do is store the Product ID, and the Qty. Thats it. Everything else is for the purpose of Viewing the Cart, and Creating the Order. The order totals are separate from the cart, because for most orders there will be other charges like shipping / tax. and/or there might be promotions which change the final price.

    So you might decide to include the Product name in the Cart to make it easier to display. And storing the ship weight is reasonable. But even storing the price in the cart can be dangerous. What if the price is raised – or lowered – while the shopper is shopping? These might be edge cases, but it shows you how ‘stale’ the information in a cart can get.

    The example you cited is great because you very quickly see – the cart is built to track one line item at a time. For any kind of logic like – if you buy 3 of these, you get the third one for free – you could build that kind of logic into the cart – but its going to become messy spaghetti very quickly!

    so what to do? get the cart object – with your cart items – and pass that to a promotion model. the promotion model loops through all the items in the cart – and THEN makes the adjustments – which are passed to your order methods. by having a promotion model, we are keeping the business rules for promotions separate from the cart. Most importantly

    we are not changing anything in the cart !

    we are applying the promotion to the items in the cart. much more flexible, and its easy to show the person how much money they saved, because you havent tried to rewrite the original cart pricing.

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

Sidebar

Related Questions

I've successfully created a simple app and push it to Heroku. In the first
I've successfully created an NSCollectionView and added a label to the view prototype in
I have successfully created an app that reads from a bundled .plist file and
I have followed this tutorial http://netbeans.org/kb/docs/websvc/gs-axis.html and successfully created the web service. When i
I have created a simple WCF service by following a MSDN tutorial. I successfully
I am successfully created restful web service and deploy it in Apache Tomcat 7.0.
I'm creating an XML file using Perl and XML::Simple module. I successfully create the
I successfully created database on my local server using Code First, migrated it to
I successfully created a project using Wicket quickstart and turned it into an Eclipse
I have successfully created a feature in sharepoint that modifies the existing edit dialog

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.