Post by openmycart.com » Tue Mar 15, 2011 11:14 pm

Code: Select all

<?php if ($products[$j]['units_sold']) { ?>
<?php echo $products[$j]['units_sold']; ?>
<?php } else { echo "0";} ?>
but what mean product = 0 ?

Find and get many various of opencart modules, themes, mods, etc for your opencart store at http://www.openmycart.com/oc/, OPENCART SITE customization and Maintenance supports at here


User avatar
Active Member

Posts

Joined
Tue Oct 12, 2010 4:47 am


Post by dim565 » Wed Mar 16, 2011 1:50 am

If the goods are not bought one yet - will show 0. Without this, nothing is displayed

New member

Posts

Joined
Fri Feb 18, 2011 12:48 pm

Post by openmycart.com » Wed Mar 16, 2011 5:39 am

but from your code it look like if goods sold then show sold else show 0, I don't think so why show goods to 0 if another not sold, CMIIW

Find and get many various of opencart modules, themes, mods, etc for your opencart store at http://www.openmycart.com/oc/, OPENCART SITE customization and Maintenance supports at here


User avatar
Active Member

Posts

Joined
Tue Oct 12, 2010 4:47 am


Post by kxs1 » Fri Jan 06, 2012 1:13 am

As a newbie, I tried to follow this thread with no luck. Is there a summary of the tasks required on how to Display Units Sold on Product and Category pages? Also is there a quick way to use the vQmod? thank you in advance.

Newbie

Posts

Joined
Fri Jan 06, 2012 1:09 am

Post by scd1982 » Sat Apr 28, 2012 12:03 am

fido-x wrote:Let's see, the order_product table stores the products that have sold, the order table records the order status. So, you need to count the products in the order_products table based on the product_id where the order status in the order table is set to "complete". Easy!

Insert the following function into "catalog/model/catalog/product.php":

Code: Select all

public function getUnitsSold($product_id) {
    $query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "order_product` op LEFT JOIN `" . DB_PREFIX . "order` o ON (op.order_id = o.order_id) WHERE o.order_status_id = '5' AND op.product_id = '" . (int)$product_id . "'");
    if ($query->row) {
        return $query->row['total'];
    } else {
        return FALSE;
    }
} 
Insert the following into "catalog/language/english/product/product.php":

Code: Select all

$_['text_units_sold'] = 'Units Sold:'; 
Insert the following into "catalog/controller/product/product.php":

Code: Select all

$this->data['text_units_sold'] = $this->language->get('text_units_sold');
$this->data['units_sold'] = $this->model_catalog_product->getUnitsSold($product_id); 
before (line 157):

Code: Select all

$this->load->model('catalog/review'); 
Then insert the following into "catalog/view/theme/default/template/product/product.tpl":

Code: Select all

<?php if ($units_sold) { ?>
<tr>
  <td><b><?php echo $text_units_sold; ?></b></td>
  <td><?php echo $units_sold; ?></td>
</tr>
<?php } ?>
before (around line 35 in the default):

Code: Select all

<?php if ($manufacturer) { ?>
I slightly modified the product.tpl code and the $text_units_sold language so I could get this to work sort of as a count down using the existing $stock.

Might be useful for someone who manufactures/ships orders in bulk to display how many more of an item needs to be purchased until they are produced/shipped.

The only way this works though is if you use the product's quantity field as the number of sales needed to produce the product, and set the subtract stock to "no". If the product being sold is going to go through multiple batches, you'll have to add the number to the existing quantity to get it to work correctly. (i.e. first batch of 100 is sold, produced, shipped, and now a second batch of 100 is up for sale - set quantity to 200).

It's not neat, not the best way to do it, and probably could stand to use some improvement. But it works..

Code: Select all

<?php if ($units_sold) { ?>
			<table>
			<tr>
				<td><b><?php echo $text_units_sold; ?></b></td>
				<td><?php if ($stock - $units_sold < 1)
				echo $text_item_live;
				else 
				echo $stock - $units_sold; 
				?></td>
			</tr>
			</table><br />
		<?php } ?>
Also added text_item_live to the language and controller files:
Insert the following into "catalog/language/english/product/product.php":

Code: Select all

$_['text_item_live']    = 'Required minimum reached. Item will ship in 3 business days.';
Insert the following into "catalog/controller/product/product.php":

Code: Select all

$this->data['text_item_live'] = $this->language->get('text_item_live');
For both, insert the code just below where fido-x suggested earlier.

I usually forget to mention I'm using OC v1.4.9.4


New member

Posts

Joined
Tue Mar 27, 2012 3:57 am

Post by ankurgambhir3 » Sat Mar 30, 2013 8:13 pm

i am trying this but not working please help me with this

Newbie

Posts

Joined
Mon Jul 23, 2012 8:56 pm

Post by beerlim » Tue Oct 31, 2017 12:29 am

For OC V3.0.2.0
I corrected the SQL for the 0 return (NULL return).
I also wrapped it in vqMod based on a instruction I found somewhere online and it worked first try. Pretty good
So here the XML you need to drop into /vqmod/xml/

/Marcel


New member

Posts

Joined
Tue May 23, 2017 5:39 pm

Post by IP_CAM » Tue Oct 31, 2017 1:59 am

Good Work ! And some for older OC Versions exist also, just to round up this topic ;)
Ernie
EC Sold Items - Number Bought free, OC v.1.5.4 - 2.0.3.1:
https://www.opencart.com/index.php?rout ... n_id=15185
Image
---
Custom Stock Display free, OC v.1.5.4 - 1.5.6.4:
https://www.opencart.com/index.php?rout ... n_id=15786

For Sale: Top URL's, including an OpenCart V-Pro Shop!
A wide range of matching Designs can be seen here: http://www.opencart.li
For Information on URL's offered, please contact me at: jti@jacob.ch
Hundreds of Mods in 380+ Repositories for OC v.1.5.x - v.2.3.x
to be found on my Github Site: https://github.com/IP-CAM
Image


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by yancp » Sun Apr 08, 2018 12:10 am

I am interested in something similar: to show number of products sold per order in admin's order list, is there such an extension, i did not find any in marketplace?

Newbie

Posts

Joined
Wed Feb 21, 2018 7:57 am
Who is online

Users browsing this forum: No registered users and 19 guests