Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Shopping cart content class


Psytanium

Recommended Posts

It's inadvisable to add more columns to cart->contents, as it is stored in the session.  That's why price and other characteristics are loaded by get_products rather than stored in the cart. 

If you are making custom attributes, consider changing the products ID.  That's how that has typically been implemented in the past.  Or consider doing something like product bundles where the user sees one product but behind the scenes there is more than one. 

The quantity is set in includes/actions. 

Always back up before making changes.

Link to comment
Share on other sites

11 hours ago, ecartz said:

It's inadvisable to add more columns to cart->contents, as it is stored in the session.  That's why price and other characteristics are loaded by get_products rather than stored in the cart. 

If you are making custom attributes, consider changing the products ID.  That's how that has typically been implemented in the past.  Or consider doing something like product bundles where the user sees one product but behind the scenes there is more than one. 

The quantity is set in includes/actions

Thank you for explaining this issue, in the file i want to modify this function :

function count_contents() { // get total number of items in cart
      $total_items = 0;
      if (is_array($this->contents)) {
        reset($this->contents);
        while (list($products_id, ) = each($this->contents)) {
          $total_items += $this->get_quantity($products_id);
        }
      }

For some reasons, i want to count specific file and do something similar to

function count_contents() { // get total number of items in cart
      $total_items = 0;
      if (is_array($this->contents)) {
        reset($this->contents);
        while (list($products_id, ) = each($this->contents)) {
			// modification to count specific products
			if ($this->contents[$products_id]['newfield'] == 1) {
				$total_items += $this->get_quantity($products_id);
			}
        }
      }

any possible solution ? thanks

btw i didn't find includes/action in my directories, i'm working on 2.3.4

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...