Welcome, Guest
Username: Password: Remember me
Use this Category for your support questions about Virtuemart Template - PureMart (SKU# FLEX-00010)

TOPIC: Shipping weight incorrect with stockable variant

Shipping weight incorrect with stockable variant 11 years 3 months ago #2128

Hi there,
Love this template, but found with having to use stockable variant with puremart, the shipping weight is incorrect. If I have a size medium that's 0.75 pounds, and a parent product that's 0.0000 pounds, rather than calculating the child products, it tries adding the parent product weight only, so shipping quote is off. It should total weight: 0.75 but instead show's 0.0000. Is there a way to fix this? Thanks,
The topic has been locked.

Shipping weight incorrect with stockable variant 11 years 3 months ago #2130

Here's a solution, if anyone else needs help with this too! It's an issue with stockable.php (root/plugins/vmcustom/stockable/stockable.php) Hope this helps someone out there! Btw, I just used the weight part of this and commented out what I didn't need in my own.

Find this Code:
public function plgVmOnAddToCart(&$product){
		$customPlugin = JRequest::getVar('customPlugin',0);
 
		if ($customPlugin) {
			$db = JFactory::getDBO();
			$query = 'SELECT  C.* , field.*
				FROM `#__virtuemart_customs` AS C
				LEFT JOIN `#__virtuemart_product_customfields` AS field ON C.`virtuemart_custom_id` = field.`virtuemart_custom_id`
				WHERE `virtuemart_product_id` =' . $product->virtuemart_product_id.' and `custom_element`="'.$this->_name.'"';
			$query .=' and is_cart_attribute = 1';
			$db->setQuery($query);
			$productCustomsPrice = $db->loadObject();
			if (!$productCustomsPrice) return null;
			// if ( !in_array($this->_name,$customPlugin[$productCustomsPrice->virtuemart_custom_id]) ) return false;
			$selected = $customPlugin[$productCustomsPrice->virtuemart_customfield_id]['stockable']['child_id'];
 
			if (!$child = $this->plgVmCalculateCustomVariant($product, $productCustomsPrice,$selected) ) return false;
			if ($child->product_sku)
				$product->product_sku = $child->product_sku;
			if ($child->product_name)
				$product->product_name = $child->product_name;
			$product->product_in_stock = $child->product_in_stock;
		}
	}

Replace with:
public function plgVmOnAddToCart(&$product){
		$customPlugin = JRequest::getVar('customPlugin',0);
 
		if ($customPlugin) {
			$db = JFactory::getDBO();
			$query = 'SELECT  C.* , field.*
				FROM `#__virtuemart_customs` AS C
				LEFT JOIN `#__virtuemart_product_customfields` AS field ON C.`virtuemart_custom_id` = field.`virtuemart_custom_id`
				WHERE `virtuemart_product_id` =' . $product->virtuemart_product_id.' and `custom_element`="'.$this->_name.'"';
			$query .=' and is_cart_attribute = 1';
			$db->setQuery($query);
			$productCustomsPrice = $db->loadObject();
			if (!$productCustomsPrice) return null;
			// if ( !in_array($this->_name,$customPlugin[$productCustomsPrice->virtuemart_custom_id]) ) return false;
			$selected = $customPlugin[$productCustomsPrice->virtuemart_customfield_id]['stockable']['child_id'];
 
			if (!$child = $this->plgVmCalculateCustomVariant($product, $productCustomsPrice,$selected) ) return false;
 
			if ($child->product_sku)       $product->product_sku       = $child->product_sku;
			if ($child->product_name)    $product->product_name    = $child->product_name;
			$product->product_in_stock = $child->product_in_stock;  // Override this even if null. 
 
			if ($child->product_weight)    $product->product_weight = $child->product_weight;
			if ($child ->product_weight_uom) $product->product_weight_uom = $child->product_weight_uom;
			if ($child->product_length) $product->product_length = $child->product_length;
			if ($child->product_width) $product->product_width = $child->product_width;
			if ($child->product_height) $product->product_height = $child->product_height;
			if ($child->product_lwh_uom) $product->product_lwh_uom = $child->product_lwh_uom;
			// if ($child->min_order_level) $product->min_order_level = $child->min_order_level;
			// if ($child->max_order_level) $product->max_order_level = $child->max_order_level;
		}
	}

Find this code:
function getValideChild($child_id ) {
		$db = JFactory::getDBO();
		$q = 'SELECT `product_sku`,`product_name`,`product_in_stock`,`product_ordered`,`product_availability` FROM `#__virtuemart_products` JOIN `#__virtuemart_products_'.VMLANG.'` as l using (`virtuemart_product_id`) WHERE `published`=1 and `virtuemart_product_id` ='.(int)$child_id ;
		$db->setQuery($q);
		$child = $db->loadObject();
		if ($child) {
			if ('disableit_children' === $this->stockhandle) {
				$stock = $child->product_in_stock - $child->product_ordered ;
				if ($stock>0)return $child ;
				else return false ;
			}
			else return $child ;
		}
		return false ;
	}

Replace with this:
function getValideChild($child_id ) {
		$db = JFactory::getDBO();
		$q = 'SELECT `product_sku`,`product_name`,`product_in_stock`,`product_ordered`,`product_availability`,`product_weight`,`product_weight_uom`,`product_length`,`product_width`,`product_height`,`product_lwh_uom` FROM `#__virtuemart_prfoducts` JOIN `#__virtuemart_products_'.VMLANG.'` as l using (`virtuemart_product_id`) WHERE `published`=1 and `virtuemart_product_id` ='.(int)$child_id ;
		$db->setQuery($q);
		$child = $db->loadObject();
		if ($child) {
			if ('disableit_children' === $this->stockhandle) {
				$stock = $child->product_in_stock - $child->product_ordered ;
				if ($stock>0)return $child ;
				else return false ;
			}
			else return $child ;
		}
		return false ;
	}
The topic has been locked.

Shipping weight incorrect with stockable variant 11 years 3 months ago #2152

Hi,

Thanks for rising an issue about stockable plugin and providing the solution for others.

For forum clearance, case solved. Topis is closed.

Regards.
Forum Support.
The topic has been locked.
Time to create page: 0.408 seconds

MaterialMart

for Virtuemart 3

Google's Material Design has finally arrived to Virtuemart

Virtumart Template - MaterialMart Virtumart Template - CleanMart Virtumart Template - CleanMart Virtumart Template - CleanMart

Fully responsive!

Buy Now   |   Live Demo