function getProductBySku($sku) { global $database, $logger; $logger->debug(get_class($this) . "::getProductBySku({$sku})"); $prod = new Product(); $ps_prod = new ps_product(); $ps_cat = new ps_product_category(); $query = "select product_id from #__vm_product where product_sku=" . $sku; $database->loadQuery($query); $id = $db->loadResult(); $prod->setOid($id); $prod->setName($ps_prod->get_field('product_name')); $prod->setFlypage($ps_prod->get_flypage($id)); $prod->setCategoryId($ps_cat->get_cid($id)); return $prod; }
function getItems(&$params) { global $CURRENCY_DISPLAY, $sess, $mm_action_url, $VM_LANG; $db = new ps_DB; if($rows = $this->getProductSKU( $this->NumberOfProducts, $this->SortMethod, $this->vmcategories, $this->featuredProducts, $this->specific_product_ids, $this->source, $this->catfilter )) { $ps_product = new ps_product; $ps_product_category = new ps_product_category; $pro_skus = implode("','", $rows); $limit = $this->NumberOfProducts; if($limit>0) { $limit = "LIMIT $limit"; } else { $limit = ""; } $q = "SELECT product_id, product_name, product_parent_id, product_thumb_image, product_desc, product_full_image FROM #__{vm}_product AS p WHERE product_sku in ('$pro_skus')"; switch( $this->SortMethod ) { case 'random': $q .= "\n ORDER BY RAND() $limit"; break; case 'newest': $q .= "\n ORDER BY p.cdate DESC $limit"; break; case 'oldest': $q .= "\n ORDER BY p.cdate ASC $limit"; break; default: $q .= "\n ORDER BY p.cdate DESC $limit"; break; } $db->setQuery( $q ); $items = $db->loadObjectList(); //var_dump($items);die; foreach($items as &$item) { $product_id = $item->product_id; $cid = $ps_product_category->get_cid( $product_id ); $product_name = $item->product_name; $item->title = $product_name; if ($item->product_parent_id) { $url = "?page=shop.product_details&category_id=$cid&flypage=".$ps_product->get_flypage($item->product_parent_id); $url .= "&product_id=" . $item->product_parent_id; } else { $url = "?page=shop.product_details&category_id=$cid&flypage=".$ps_product->get_flypage($item->product_id); $url .= "&product_id=" . $item->product_id; } $product_link = $sess->url($mm_action_url. "index.php" . $url); $item->link = $product_link; $product_thumb_image = $item->product_full_image; //$img = $this->image_url( $product_thumb_image, "alt=\"".$product_name."\""); $item->image = IMAGEPATH.'product/'.$product_thumb_image; $item->fulltext = $item->product_desc; $item->introtext = $item->product_desc; $price_base = $this->get_price($ps_product, $item->product_id); $price_ps = $ps_product->get_price($item->product_id, true); if (_SHOW_PRICES == '1' && $this->show_price) { // Show price, but without "including X% tax" $item->price = $CURRENCY_DISPLAY->getFullValue($price_base[1]); } if (USE_AS_CATALOGUE != 1 && $this->show_addtocart && isset($price_ps) && $price_ps['product_price'] // Product must have a price to add it to cart /*&& !$ps_product->product_has_attributes($item->product_id, true) // Parent Products and Products with attributes can't be added to cart this way*/ ) { $url = "?page=shop.cart&func=cartAdd&product_id=" . $item->product_id; $addtocart_link = $sess->url($mm_action_url. "index.php" . $url); $item->addtocart_link = $addtocart_link; } } return $this->update($params, $items); } else return array(); }
$order_total = 0; $coupon_discount = vmGet($_SESSION, 'coupon_discount', 0); $coupon_discount_before = $coupon_discount_after = $payment_discount_before = $payment_discount_after = $tax = $shipping = false; $product_rows = array(); for ($i = 0; $i < $cart["idx"]; $i++) { // Added for the zone shipping module $vars["zone_qty"] += $cart[$i]["quantity"]; if ($i % 2) { $product_rows[$i]['row_color'] = "sectiontableentry2"; } else { $product_rows[$i]['row_color'] = "sectiontableentry1"; } // Get product parent id if exists $product_parent_id = $ps_product->get_field($cart[$i]["product_id"], "product_parent_id"); // Get flypage for this product $flypage = $ps_product->get_flypage($cart[$i]["product_id"]); // Build URL based on whether item or product if ($product_parent_id) { $url = $sess->url(URL . basename($_SERVER['PHP_SELF']) . "?page=shop.product_details&flypage={$flypage}&product_id={$product_parent_id}"); } else { $url = $sess->url(URL . basename($_SERVER['PHP_SELF']) . "?page=shop.product_details&flypage={$flypage}&product_id=" . $_SESSION['cart'][$i]["product_id"]); } $product_rows[$i]['product_name'] = "<a href=\"{$url}\"><strong>" . shopMakeHtmlSafe($ps_product->get_field($_SESSION['cart'][$i]["product_id"], "product_name")) . "</strong></a><br />" . $ps_product->getDescriptionWithTax($_SESSION['cart'][$i]["description"], $_SESSION['cart'][$i]["product_id"]); // Display attribute values if this an item $product_rows[$i]['product_attributes'] = ""; if ($product_parent_id) { $db_detail = $ps_product->attribute_sql($cart[$i]["product_id"], $product_parent_id); while ($db_detail->next_record()) { $product_rows[$i]['product_attributes'] .= "<br />" . $db_detail->f("attribute_name") . " "; $product_rows[$i]['product_attributes'] .= "(" . $db_detail->f("attribute_value") . ")"; }
/** * Lists all child/sister products of the given product * * @param int $product_id * @return string HTML code with Items, attributes & price */ function list_attribute_list($product_id, $display_use_parent, $child_link, $display_type, $cls_sfuffix, $child_ids, $dw, $aw, $display_header, $product_list_type, $product_list) { global $CURRENCY_DISPLAY, $mm_action_url; require_once CLASSPATH . 'ps_product.php'; $ps_product = new ps_product(); require_once CLASSPATH . 'ps_product_type.php'; $ps_product_type = new ps_product_type(); $Itemid = vmGet($_REQUEST, 'Itemid', ""); $category_id = vmGet($_REQUEST, 'category_id', ""); $curr_product = vmGet($_REQUEST, 'product_id', ""); $db = new ps_DB(); $db_sku = new ps_DB(); $db_item = new ps_DB(); $tpl = vmTemplate::getInstance(); $price = $ps_product->get_adjusted_attribute_price($product_id); $tpl->set("cls_suffix", $cls_sfuffix); $tpl->set("product_id", $product_id); $tpl->set("display_header", $display_header); $tpl->set("display_product_type", $product_list_type); $tpl->set("product_price", $price['product_price']); $html = ''; // Get list of children $pp = $ps_product->parent_has_children($product_id); if ($pp) { $q = "SELECT product_id,product_name,product_parent_id,product_sku,product_in_stock,product_full_image,product_thumb_image FROM #__{vm}_product WHERE product_publish='Y' AND product_parent_id='{$product_id}' "; } else { $q = "SELECT product_id,product_name,product_parent_id,product_sku,product_in_stock,product_full_image,product_thumb_image FROM #__{vm}_product WHERE product_publish='Y' AND product_id='{$product_id}' "; } if ($child_ids) { $ids = explode(",", $child_ids); $child_array = array(); $parent_array = array(); foreach ($ids as $extra_id) { if ($ps_product->parent_has_children($extra_id)) { $parent_array[] = $extra_id; } else { $child_array[] = $extra_id; } } $parent_ids = implode(',', $parent_array); $child_ids = implode(',', $child_array); if ($child_ids) { $q .= "UNION ALL SELECT product_id,product_name,product_parent_id,product_sku,product_in_stock,product_full_image,product_thumb_image FROM #__{vm}_product WHERE product_publish='Y' AND product_id IN ({$child_ids}) "; } if ($parent_ids) { $q .= "UNION ALL SELECT product_id,product_name,product_parent_id,product_sku,product_in_stock,product_full_image,product_thumb_image FROM #__{vm}_product WHERE product_publish='Y' AND product_parent_id IN ({$parent_ids})"; } } $db->query($q); if ($pp) { $master_id = $product_id; } else { $master_id = $db->f("product_id"); } $main_master = $master_id; $master_child_count = 0; if ($db->num_rows() < 1) { // Try to Get list of sisters & brothers $q = "SELECT product_parent_id FROM #__{vm}_product WHERE product_id='{$product_id}'"; $db->setQuery($q); $db->query(); $child_id = $product_id; $product_id = $db->f("product_parent_id") ? $db->f("product_parent_id") : $product_id; $parent_id = $db->f("product_parent_id"); $q = "SELECT product_id,product_name,product_parent_id,product_sku,product_in_stock FROM #__{vm}_product WHERE product_parent_id='" . $db->f("product_parent_id") . "' AND product_parent_id<>0 AND product_publish='Y'"; $db->query($q); } if ($db->num_rows() > 0) { $products = array(); $headings = array(); $i = 0; $attrib_heading = array(); $ci = 0; while ($db->next_record()) { $parent_id = $db->f("product_parent_id"); if ($db->f("product_id") != $curr_product && @$child_id) { continue; } // Start row for this child $q = "SELECT product_id, attribute_name FROM #__{vm}_product_attribute_sku "; $q .= "WHERE product_id='" . $db->f("product_parent_id") . "' ORDER BY attribute_list ASC"; $db_sku->query($q); $attrib_value = array(); while ($db_sku->next_record()) { $q = "SELECT attribute_name,attribute_value "; $q .= "FROM #__{vm}_product_attribute WHERE "; $q .= "product_id='" . $db->f("product_id") . "' AND "; $q .= "attribute_name='" . $db_sku->f("attribute_name") . "'"; $db_item->setQuery($q); $db_item->query(); while ($db_item->next_record()) { if ($ci == 0) { $attrib_heading[] = $db_item->f("attribute_name"); $tpl->set('headings', $attrib_heading); } $attrib_value[] = $db_item->f("attribute_value"); } } if ($main_master == $parent_id) { $master_child_count++; } $tpl->set('desc_width', $dw); $tpl->set('attrib_width', $aw); // End show Header Row if ($ci % 2) { $bgcolor = "vmRowOne"; } else { $bgcolor = "vmRowTwo"; } $products[$ci]['bgcolor'] = $bgcolor; $products[$ci]['product_id'] = $db->f("product_id"); $products[$ci]["category_id"] = $category_id; $products[$ci]["Itemid"] = $Itemid; // If this is a child of a parent set the correct product_id for page return if (@$child_id && $pp) { $products[$ci]['parent_id'] = $db->f("product_id"); } else { $master_id = $parent_id; $products[$ci]['parent_id'] = $parent_id; } $flypage = $ps_product->get_flypage($products[$ci]['parent_id']); $products[$ci]["flypage"] = $flypage; // Images // If it is item get parent: $product_parent_id = $db->f("product_parent_id"); if ($product_parent_id != 0) { $dbp = new PS_db(); $dbp->query("SELECT product_full_image,product_thumb_image,product_name,product_s_desc FROM #__{vm}_product WHERE product_id='{$product_parent_id}'"); $dbp->next_record(); } $product_full_image = $parent_id != 0 && !$db->f("product_full_image") ? $dbp->f("product_full_image") : $db->f("product_full_image"); // Change $product_thumb_image = $parent_id != 0 && !$db->f("product_thumb_image") ? $dbp->f("product_thumb_image") : $db->f("product_thumb_image"); // Change $productData = $db->get_row(); $productArray = get_object_vars($productData); $productArray["product_id"] = $db->f("product_id"); $productArray["product_full_image"] = $product_full_image; // to display the full image on flypage $productArray["product_thumb_image"] = $product_thumb_image; $tpl->set('productArray', $productArray); foreach ($productArray as $property => $value) { $tpl->set($property, $value); } // Assemble the thumbnail image as a link to the full image // This function is defined in the theme (theme.php) $product_image = $tpl->vmBuildFullImageLink($productArray); $products[$ci]['product_image'] = $product_image; //Product Description $link = ""; if ($child_link == "Y" && !@$child_id) { $link = "<input type=\"hidden\" id=\"index_id" . $db->f("product_id") . "\" value=\"" . $db->f("product_id") . "\" />\n"; // If content plugins are enabled, reload the whole page; otherwise, use ajax if (VM_CONTENT_PLUGINS_ENABLE == '1') { $link .= "<a name=\"" . $db->f("product_name") . $db->f("product_id") . "\" onclick=\"var id = \$('index_id" . $db->f("product_id") . "').value; if(id != '') { document.location = '" . $mm_action_url . "index.php?option=com_virtuemart&page=shop.product_details&flypage={$flypage}&Itemid={$Itemid}&category_id={$category_id}&product_id=' + id; }\" >"; } else { $link .= "<a name=\"" . $db->f("product_name") . $db->f("product_id") . "\" onclick=\"var id = \$('index_id" . $db->f("product_id") . "').value; if(id != '') { loadNewPage( 'vmMainPage', '" . $mm_action_url . "index2.php?option=com_virtuemart&page=shop.product_details&flypage={$flypage}&Itemid={$Itemid}&category_id={$category_id}&product_id=' + id ); }\" >"; } $tpl->set('child_link', true); } else { $tpl->set('child_link', false); } $html1 = $db->f("product_name"); if ($child_link == "Y" && !@$child_id) { $html1 .= "</a>"; } $products[$ci]['product_title'] = $link . $html1; // For each child get attribute values by looping through attribute list foreach ($attrib_value as $attribute) { $products[$ci]['attrib_value'][] = $attribute; } //Show the quantity Box $products[$ci]['quantity_box'] = $this->show_quantity_box($master_id, $db->f("product_id"), $product_list, $display_use_parent); // Attributes for this item are done. // Now get item price $price = $ps_product->get_price($db->f("product_id")); $price["product_price"] = $GLOBALS['CURRENCY']->convert($price["product_price"], $price["product_currency"]); $actual_price = $ps_product->get_adjusted_attribute_price($db->f("product_id")); $actual_price["product_price"] = $GLOBALS['CURRENCY']->convert($actual_price["product_price"], $actual_price["product_currency"]); if ($_SESSION["auth"]["show_price_including_tax"] == 1) { $tax_rate = 1 + $ps_product->get_product_taxrate($db->f("product_id")); $price['product_price'] *= $tax_rate; $actual_price['product_price'] *= $tax_rate; } $products[$ci]['price'] = $CURRENCY_DISPLAY->getFullValue($price["product_price"]); $products[$ci]['actual_price'] = $CURRENCY_DISPLAY->getFullValue($actual_price["product_price"]); // Ouput Product Type if ($db->f("product_parent_id") != $product_id) { $product_id = $db->f("product_parent_id"); } $product_type = ""; if ($product_id != 0 && !$ps_product_type->product_in_product_type($db->f("product_id"))) { $product_type = $ps_product_type->list_product_type($product_id); } else { $product_type = $ps_product_type->list_product_type($db->f("product_id")); } $products[$ci]['product_type'] = $product_type; // Child stock if ($display_use_parent == 'Y' && !empty($master_id)) { $id = $master_id; } else { $id = $db->f("product_id"); } $products[$ci]['product_in_stock'] = ps_product::get_field($id, 'product_in_stock'); // Output Advanced Attributes $products[$ci]['advanced_attribute'] = $this->list_advanced_attribute($db->f("product_id")); $products[$ci]['custom_attribute'] = $this->list_custom_attribute($db->f("product_id")); $ci++; } if ($display_type == "radio") { $list_type = "radio"; } else { $list_type = "list"; } // Get template and fill $tpl->set('products', $products); $master_child_count = $master_child_count == 0 ? 1 : $master_child_count; $tpl->set('child_count', $master_child_count); if ($product_list == "Y") { $html = $tpl->fetch('product_details/includes/addtocart_list_single.tpl.php'); } else { $list_type = "multi"; $html = $tpl->fetch('product_details/includes/addtocart_list_multi.tpl.php'); } } else { $html = "<input type=\"hidden\" name=\"product_id\" value=\"{$product_id}\" />\n"; $html .= "<input type=\"hidden\" name=\"prod_id[]\" value=\"{$product_id}\" />\n"; // This function lists the "advanced" simple attributes $html .= $this->list_advanced_attribute($product_id); // This function lists the "custom" simple attributes $html .= $this->list_custom_attribute($product_id); $html .= '<br />'; $list_type = "drop"; } return array($html, $list_type); }
?> <table border="0" cellpadding="0" cellspacing="0" width="100%" class="bestseller-container"> <?php while ($db->next_record()) { if ($i == 0) { $sectioncolor = "sectiontableentry2"; $i += 1; } else { $sectioncolor = "sectiontableentry1"; $i -= 1; } if( !$db->f('category_flypage') ) { $flypage = ps_product::get_flypage( $db->f('product_id')); } else { $flypage = $db->f('category_flypage'); } $tt_item++; $pid = $db->f("product_parent_id") ? $db->f("product_parent_id") : $db->f("product_id"); ?> <tr class="<?php echo $sectioncolor ?>"> <td width="12%"><?php printf( $tt_item); ?>.</td> <td width="85%"> <a class="bestseller" href="<?php $sess->purl(URL . "index.php?page=shop.product_details&flypage=$flypage&product_id=" . $pid . "&category_id=" . $db->f("category_id")) ?>"> <?php $db->p("product_name"); ?> </a> </td>
function notify_list($product_id) { global $sess, $mosConfig_fromname, $VM_LANG; $option = vmGet($_REQUEST, 'option'); $product_id = intval($product_id); if ($product_id == 0) { return False; } $dbv = new ps_DB(); $qt = "SELECT contact_email from #__{vm}_vendor "; $qt .= "WHERE vendor_id='1'"; $dbv->query($qt); $dbv->next_record(); $from_email = $dbv->f("contact_email"); $db = new ps_DB(); $q = 'SELECT notify_email FROM #__{vm}_waiting_list WHERE '; $q .= 'notified="0" AND product_id=' . $product_id; $db->query($q); require_once CLASSPATH . 'ps_product.php'; $ps_product = new ps_product(); while ($db->next_record()) { // get the product name for the e-mail $product_name = $ps_product->get_field($product_id, "product_name"); // lets make the e-mail up from the info we have $notice_subject = sprintf($VM_LANG->_('PRODUCT_WAITING_LIST_EMAIL_SUBJECT'), $product_name); $flypage = $ps_product->get_flypage($product_id); // now get the url information $url = URL . "index.php?page=shop.product_details&flypage={$flypage}&product_id={$product_id}&option={$option}&Itemid=" . $sess->getShopItemid(); $notice_body = sprintf($VM_LANG->_('PRODUCT_WAITING_LIST_EMAIL_TEXT'), $product_name, $url); // send the e-mail $shopper_email = $db->f("notify_email"); vmMail($from_email, $mosConfig_fromname, $shopper_email, $notice_subject, $notice_body, ""); $this->update($shopper_email, $product_id); } return True; }
for ($i = 0; $i < $cart["idx"]; $i++) { // Added for the zone shipping module $vars["zone_qty"] += $cart[$i]["quantity"]; if ($i % 2) { $product_rows[$i]['row_color'] = "sectiontableentry2"; } else { $product_rows[$i]['row_color'] = "sectiontableentry1"; } // Get product parent id if exists $product_parent_id = $ps_product->get_field($cart[$i]["product_id"], "product_parent_id"); // Get flypage for this product $flypage_id = $product_parent_id; if ($flypage_id == 0) { $flypage_id = $cart[$i]["product_id"]; } $flypage = $ps_product->get_flypage($flypage_id); $category_id = vmGet($cart[$i], 'category_id', 0); // Build URL based on whether item or product if ($product_parent_id) { $url = $sess->url(URL . basename($_SERVER['PHP_SELF']) . "?page=shop.product_details&flypage={$flypage}&product_id={$product_parent_id}&category_id={$category_id}"); } else { $url = $sess->url(URL . basename($_SERVER['PHP_SELF']) . "?page=shop.product_details&flypage={$flypage}&product_id=" . $_SESSION['cart'][$i]["product_id"] . "&category_id={$category_id}"); } $product_rows[$i]['product_name'] = "<a href=\"{$url}\"><strong>" . shopMakeHtmlSafe($ps_product->get_field($_SESSION['cart'][$i]["product_id"], "product_name")) . "</strong></a><br />" . $ps_product->getDescriptionWithTax($_SESSION['cart'][$i]["description"], $_SESSION['cart'][$i]["product_id"]); // Display attribute values if this an item $product_rows[$i]['product_attributes'] = ""; if ($product_parent_id) { $db_detail = $ps_product->attribute_sql($cart[$i]["product_id"], $product_parent_id); while ($db_detail->next_record()) { $product_rows[$i]['product_attributes'] .= "<br />" . $db_detail->f("attribute_name") . " "; $product_rows[$i]['product_attributes'] .= "(" . $db_detail->f("attribute_value") . ")";
/** * adds an item to the shopping cart * @author pablo * @param array $d */ function add(&$d) { global $sess, $VM_LANG, $cart, $vmLogger, $func; $d = $GLOBALS['vmInputFilter']->process($d); include_class("product"); $db = new ps_DB(); $ci = 0; $request_stock = ""; $total_quantity = 0; $total_updated = 0; $total_deleted = 0; $_SESSION['last_page'] = "shop.product_details"; if (!empty($d['product_id']) && !isset($d["prod_id"])) { if (empty($d['prod_id'])) { $d['prod_id'] = array(); } if (is_array($d['product_id'])) { $d['prod_id'] = array_merge($d['prod_id'], $d['product_id']); } else { $d['prod_id'] = array_merge($d['prod_id'], array($d['product_id'])); } } //Check to see if a prod_id has been set if (!isset($d["prod_id"])) { return true; } $multiple_products = sizeof($d["prod_id"]); //Iterate through the prod_id's and perform an add to cart for each one for ($ikey = 0; $ikey < $multiple_products; $ikey++) { // Create single array from multi array $key_fields = array_keys($d); foreach ($key_fields as $key) { if (is_array($d[$key])) { $e[$key] = @$d[$key][$ikey]; } else { $e[$key] = $d[$key]; } } if ($multiple_products > 1) { $func = "cartUpdate"; } $e['product_id'] = $d['product_id']; $e['Itemid'] = $d['Itemid']; if (is_array($d["prod_id"])) { $product_id = $d["prod_id"][$ikey]; } else { $product_id = $e["prod_id"]; } if (is_array($d["quantity"])) { $quantity = @$d['quantity'][$ikey]; } else { $quantity = @$e['quantity']; } // Check for negative quantity if ($quantity < 0) { vmRequest::setVar('product_id', $product_id); $vmLogger->warning($VM_LANG->_('PHPSHOP_CART_ERROR_NO_NEGATIVE', false)); return False; } if (!is_numeric($quantity)) { vmRequest::setVar('product_id', $product_id); $vmLogger->warning($VM_LANG->_('PHPSHOP_CART_ERROR_NO_VALID_QUANTITY', false)); return False; } $quantity = intval($quantity); // Check to see if checking stock quantity if (CHECK_STOCK) { $product_in_stock = ps_product::get_field($product_id, 'product_in_stock'); if (empty($product_in_stock)) { $product_in_stock = 0; } if ($quantity > $product_in_stock) { //Create an array for out of stock items and continue to next item $request_stock[$ci]['product_id'] = $product_id; $request_stock[$ci]['quantity'] = $quantity; $ci++; continue; } } // Check if product exists and is published if (!ps_product::product_exists($product_id)) { $vmLogger->tip($VM_LANG->_('VM_CART_PRODUCT_NOTEXIST', false)); return false; } // Quick add of item $q = "SELECT product_id FROM #__{vm}_product WHERE "; $q .= "product_parent_id = " . (int) $product_id; $db->query($q); if ($db->num_rows()) { vmRequest::setVar('product_id', $e["product_id"]); $vmLogger->tip($VM_LANG->_('PHPSHOP_CART_SELECT_ITEM', false)); $_REQUEST['flypage'] = ps_product::get_flypage($e["product_id"]); $GLOBALS['page'] = 'shop.product_details'; return true; } // Check to see if we already have it $updated = 0; $result = ps_product_attribute::cartGetAttributes($e); if ($result["attribute_given"] == false && !empty($result["advanced_attribute_list"]) || $multiple_products == 1 && ($result["custom_attribute_given"] == false && !empty($result["custom_attribute_list"]))) { $_REQUEST['flypage'] = ps_product::get_flypage($product_id); $GLOBALS['page'] = 'shop.product_details'; $vmLogger->tip($VM_LANG->_('PHPSHOP_CART_SELECT_ITEM', false)); return true; } //Check for empty custom field and quantity>0 for multiple addto //Normally means no info added to a custom field, but once added to a cart the quantity is automatically placed //If another item is added and the custom field is left blank for another product already added this will just ignore that item if ($multiple_products != 1 && $quantity != 0 && ($result["custom_attribute_given"] == false && !empty($result["custom_attribute_list"]))) { $vmLogger->tip($VM_LANG->_('PHPSHOP_CART_SELECT_ITEM', false)); continue; } // Check for duplicate and do not add to current quantity for ($i = 0; $i < $_SESSION["cart"]["idx"]; $i++) { // modified for advanced attributes if ($_SESSION['cart'][$i]["product_id"] == $product_id && $_SESSION['cart'][$i]["description"] == $e["description"]) { $updated = 1; } } list($min, $max) = ps_product::product_order_levels($product_id); if ($min != 0 && $quantity != 0 && $quantity < $min) { eval("\$msg = \"" . $VM_LANG->_('VM_CART_MIN_ORDER', false) . "\";"); $vmLogger->warning($msg); continue; } if ($max != 0 && $quantity != 0 && $quantity > $max) { eval("\$msg = \"" . $VM_LANG->_('VM_CART_MAX_ORDER', false) . "\";"); $vmLogger->warning($msg); continue; } // If we did not update then add the item if (!$updated && $quantity) { $k = $_SESSION['cart']["idx"]; $_SESSION['cart'][$k]["quantity"] = $quantity; $_SESSION['cart'][$k]["product_id"] = $product_id; $_SESSION['cart'][$k]["parent_id"] = $e["product_id"]; $_SESSION['cart'][$k]["category_id"] = vmGet($e, 'category_id', 0); // added for the advanced attribute modification $_SESSION['cart'][$k]["description"] = $e["description"]; $_SESSION['cart']["idx"]++; $total_quantity += $quantity; } else { list($updated_prod, $deleted_prod) = $this->update($e); $total_updated += $updated_prod; $total_deleted += $deleted_prod; } /* next 3 lines added by Erich for coupon code */ /* if the cart was updated we gotta update any coupon discounts to avoid ppl getting free stuff */ if (!empty($_SESSION['coupon_discount'])) { // Update the Coupon Discount !! require_once CLASSPATH . 'ps_coupon.php'; ps_coupon::process_coupon_code($d); } } // End Iteration through Prod id's $cart = $_SESSION['cart']; ps_cart::saveCart(); // Ouput info message with cart update details /* if ($total_quantity != 0 || $total_updated != 0 || $total_deleted != 0) { if ($total_quantity > 0 && $total_updated == 0) { $msg = $VM_LANG->_('VM_CART_PRODUCT_ADDED', false); } else { $msg = $VM_LANG->_('VM_CART_PRODUCT_UPDATED', false); } // Comment out the following line to turn off msg i.e. //$vmLogger->tip( $msg ); $vmLogger->info($msg); } else { if (@$request_stock) { $vmLogger->tip($VM_LANG->_('PHPSHOP_CART_GOTO_WAITING_LIST', false)); } elseif ($total_quantity == 0) { vmRequest::setVar('product_id', $product_id); $GLOBALS['last_page'] = 'shop.product_details'; $vmLogger->warning($VM_LANG->_('PHPSHOP_CART_ERROR_NO_VALID_QUANTITY', false)); return false; } else { $vmLogger->tip($VM_LANG->_('PHPSHOP_CART_QUANTITY_EXCEEDED', false)); } } // end cart update message */ // Perform notification of out of stock items if (@$request_stock) { global $notify; $_SESSION['notify'] = array(); $_SESSION['notify']['idx'] = 0; $k = 0; $notify = $_SESSION['notify']; foreach ($request_stock as $request) { $_SESSION['notify'][$k]["prod_id"] = $request['product_id']; $_SESSION['notify'][$k]["quantity"] = $request['quantity']; $_SESSION['notify']['idx']++; $k++; } if (vmIsXHR()) { $GLOBALS['vm_mainframe']->scriptRedirect($sess->url('index.php?page=shop.waiting_list&product_id=' . $product_id, true, false)); } else { vmRedirect($sess->url('index.php?page=shop.waiting_list&product_id=' . $product_id, true, false)); } } return True; }
/** * get list of product * * * @access private */ public function __getList($params) { global $sess, $mm_action_url; require_once CLASSPATH . 'ps_product.php'; $ps_product = new ps_product(); $ordering = $params->get('vm_ordering', 'cdate_asc'); $limit = $params->get('limit_items', 4); $ordering = str_replace('_', ' ', $ordering); $thumbWidth = (int) $params->get('thumbnail_width', 35); $thumbHeight = (int) $params->get('thumbnail_height', 60); $imageHeight = (int) $params->get('main_height', 300); $imageWidth = (int) $params->get('main_width', 660); $isThumb = $params->get('auto_renderthumb', 1); $image_quanlity = $params->get('image_quanlity', 100); $titleMaxChars = $params->get('title_max_chars', '100'); $isStripedTags = $params->get('auto_strip_tags', 0); $descriptionMaxChars = $params->get('description_max_chars', 100); $extraURL = $params->get('open_target') != 'modalbox' ? '' : '&tmpl=component'; if (trim($ordering[0]) == 'rand') { $ordering = " RAND() "; } $condition = LofSliderGroupVirtuemart::buildConditionQuery($params); // sql query $query = ' SELECT p.*, p.product_id, p.product_publish, p.product_sku, p.product_name, p.product_url ' . ' , p.product_s_desc, product_thumb_image, product_full_image' . ' , c.category_id, c.category_flypage' . ' FROM #__{vm}_product AS p ' . ' JOIN #__{vm}_product_category_xref as pc ON p.product_id=pc.product_id '; $query .= $condition; $query .= ' JOIN #__{vm}_category as c ON pc.category_id=c.category_id '; $query .= ' WHERE p.product_publish = \'Y\' AND c.category_publish = \'Y\' AND product_parent_id=0 '; if (CHECK_STOCK && PSHOP_SHOW_OUT_OF_STOCK_PRODUCTS != '1') { $query .= ' AND product_in_stock > 0 '; } $query .= ' ORDER BY ' . $ordering; $query .= ' LIMIT ' . $limit; require_once CLASSPATH . 'ps_product.php'; $ps_product = new ps_product(); $database = new ps_DB(); $database->query($query); $rows = $database->record; if (!empty($rows)) { foreach ($rows as $key => $item) { $tmpimage = $rows[$key]->product_full_image; if (!(strtolower(substr($tmpimage, 0, 4)) == 'http')) { $rows[$key]->product_image_url = IMAGEURL . 'product/' . $rows[$key]->product_full_image; } else { $rows[$key]->product_image_url = $rows[$key]->product_full_image; } $cid = $rows[$key]->category_id; // $rows[$key]->description = '<div class="vm-product-snapshot">'.$ps_product->product_snapshot($rows[$key]->product_sku, true, true).'</div>'; $rows[$key]->description = $this->substring($rows[$key]->product_desc, $descriptionMaxChars, $isStripedTags); $rows[$key]->introtext = $rows[$key]->product_desc; $flypage = $rows[$key]->category_flypage ? $rows[$key]->category_flypage : $ps_product->get_flypage($rows[$key]->product_id); $rows[$key]->link = '?page=shop.product_details&category_id=' . $cid . '&flypage=' . $flypage . '&product_id=' . $rows[$key]->product_id . $extraURL; $rows[$key]->link = $sess->url($mm_action_url . "index.php" . $rows[$key]->link); $rows[$key]->title = $this->substring($rows[$key]->product_name, $titleMaxChars); $rows[$key]->mainImage = $rows[$key]->thumbnail = ''; if ($rows[$key]->product_image_url && ($image = self::renderThumb($rows[$key]->product_image_url, $imageWidth, $imageHeight, $rows[$key]->title, $isThumb, $image_quanlity))) { $rows[$key]->mainImage = $image; } if ($rows[$key]->product_image_url && ($image = self::renderThumb($rows[$key]->product_image_url, $thumbWidth, $thumbHeight, $rows[$key]->title, $isThumb, $image_quanlity))) { $rows[$key]->thumbnail = $image; } $url = "?page=shop.cart&func=cartAdd&product_id=" . $rows[$key]->product_id; $rows[$key]->addtocart_link = $sess->url($mm_action_url . "index.php" . $url); } return $rows; } return array(); }