예제 #1
0
 function genHTML($catid)
 {
     require_once JPATH_BASE . '/components/com_virtuemart/virtuemart_parser.php';
     require_once CLASSPATH . 'ps_product.php';
     $this->loadProduct($catid);
     $ps_product = new ps_product();
     $i = 0;
     foreach ($this->_listPro as $pro) {
         $temp = $ps_product->product_snapshot($pro, $this->show_price, $this->show_addtocart);
         echo "<div class=\"vm_element\">" . $temp . "</div>";
         $i++;
     }
 }
예제 #2
0
 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;
 }
예제 #3
0
* @copyright Copyright (C) 2004-2009 soeren - All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* VirtueMart is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See /administrator/components/com_virtuemart/COPYRIGHT.php for copyright notices and details.
*
* http://virtuemart.net
*/
mm_showMyFileName(__FILE__);
global $ps_order_status;
require_once CLASSPATH . 'ps_checkout.php';
require_once CLASSPATH . 'ps_userfield.php';
require_once CLASSPATH . 'ps_product.php';
$ps_product = new ps_product();
$registrationfields = ps_userfield::getUserFields('registration', false, '', true, true);
$shippingfields = ps_userfield::getUserFields('shipping', false, '', true, true);
$order_id = vmRequest::getInt('order_id', 0);
if (empty($order_id)) {
    vmRedirect($_SERVER['SCRIPT_NAME'] . '?option=com_virtuemart&page=order.order_list');
}
$dbc = new ps_DB();
$q = "SELECT * FROM #__{vm}_orders WHERE order_id={$order_id} and vendor_id = {$ps_vendor_id}";
$db->query($q);
$db->next_record();
echo "<style type='text/css' media='print'>.vmNoPrint { display: none }</style>";
?>
<br />&nbsp;&nbsp;
<?php 
echo vmCommonHTML::PrintIcon();
예제 #4
0
파일: Sotvm.php 프로젝트: sergy444/joomla
		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();
	
			
	
		}		
예제 #5
0
</a>
    </td>
  </tr>
  <tr>
    <td align="left" nowrap ><?php 
echo $product_price;
?>
</td>
  </tr>
  <tr>
    <td ><a href="<?php 
echo $product_flypage;
?>
">
          <?php 
echo ps_product::image_tag($product_thumb_image, 'class="browseProductImage" border="0" title="' . $product_name . '" alt="' . $product_name . '"');
?>
       </a>
    </td>
  </tr>
  <tr>
    <td height="80" valign="top"><?php 
echo $product_s_desc;
?>
<br />
      <a style="font-size: 9px; font-weight: bold;" href="<?php 
echo $product_flypage;
?>
">[<?php 
echo $product_details;
?>
예제 #6
0
 /**
  * Retrieves the maximum and minimum quantity for the product specified by $product_id
  *
  * @param int $product_id
  * @return array
  */
 function product_order_levels($product_id)
 {
     $min_order = 0;
     $max_order = 0;
     $product_order_levels = ps_product::get_field($product_id, 'product_order_levels');
     $product_parent_id = ps_product::get_field($product_id, 'product_parent_id');
     if ($product_order_levels != ',') {
         $order_levels = $product_order_levels;
         $levels = explode(",", $order_levels);
         $min_order = array_shift($levels);
         $max_order = array_shift($levels);
     } else {
         if ($product_parent_id > 0) {
             //check parent if product_parent_id != 0
             $product_order_levels = ps_product::get_field($product_parent_id, 'product_order_levels');
             $product_parent_id = ps_product::get_field($product_parent_id, 'product_parent_id');
             if ($product_order_levels != ",") {
                 $order_levels = $product_order_levels;
                 $levels = explode(",", $order_levels);
                 $min_order = array_shift($levels);
                 $max_order = array_shift($levels);
             }
         }
     }
     return array($min_order, $max_order);
 }
예제 #7
0
* @package VirtueMart
* @subpackage html
* @copyright Copyright (C) 2004-2008 soeren - All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* VirtueMart is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See /administrator/components/com_virtuemart/COPYRIGHT.php for copyright notices and details.
*
* http://virtuemart.net
*/
mm_showMyFileName(__FILE__);
// load important class files
require_once CLASSPATH . "ps_product.php";
$ps_product = new ps_product();
require_once CLASSPATH . "ps_product_category.php";
$ps_product_category = new ps_product_category();
require_once CLASSPATH . "ps_product_files.php";
require_once CLASSPATH . "ps_reviews.php";
require_once CLASSPATH . "imageTools.class.php";
require_once CLASSPATH . "PEAR/Table.php";
require_once CLASSPATH . 'ps_product_attribute.php';
$ps_product_attribute = new ps_product_attribute();
$Itemid = $sess->getShopItemid();
$keyword1 = $vmInputFilter->safeSQL(urldecode(vmGet($_REQUEST, 'keyword1', null)));
$keyword2 = $vmInputFilter->safeSQL(urldecode(vmGet($_REQUEST, 'keyword2', null)));
$search_op = $vmInputFilter->safeSQL(vmGet($_REQUEST, 'search_op', null));
$search_limiter = $vmInputFilter->safeSQL(vmGet($_REQUEST, 'search_limiter', null));
if (empty($category_id)) {
    $category_id = $search_category;
예제 #8
0
 /**
  * Creates the Quantity Input Boxes/Radio Buttons/Lists for Products
  *
  * @param int $product_id The Parent Product ID
  * @param int $prod_id The actual Product ID
  * @param string $child
  * @param string $use_parent
  * @return string
  */
 function show_quantity_box($product_id, $prod_id, $child = false, $use_parent = 'N')
 {
     global $VM_LANG;
     $tpl = vmTemplate::getInstance();
     if ($child == 'Y') {
         //We have a child list so get the current quantity;
         $quantity = 0;
         for ($i = 0; $i < $_SESSION["cart"]["idx"]; $i++) {
             if ($_SESSION['cart'][$i]["product_id"] == $prod_id) {
                 $quantity = $_SESSION['cart'][$i]["quantity"];
             }
         }
     } else {
         $quantity = vmrequest::getInt('quantity', 1);
     }
     // Detremine which style to use
     if ($use_parent == 'Y' && !empty($product_id)) {
         $id = $product_id;
     } else {
         $id = $prod_id;
     }
     //Get style to use
     $product_in_stock = ps_product::get_field($id, 'product_in_stock');
     $quantity_options = ps_product::get_quantity_options($id);
     extract($quantity_options);
     //Start output of quantity
     //Check for incompatabilities and reset to normal
     if (CHECK_STOCK == '1' && !$product_in_stock) {
         $display_type = 'hide';
     }
     if (empty($display_type) || @$display_type == "hide" && $child == 'Y' || @$display_type == "radio" && $child == 'YM' || @$display_type == "radio" && !$child) {
         $display_type = "none";
     }
     unset($quantity_options['display_type']);
     $tpl->set('prod_id', $prod_id);
     $tpl->set('quantity', $quantity);
     $tpl->set('display_type', $display_type);
     $tpl->set('child', $child);
     $tpl->set('quantity_options', $quantity_options);
     //Determine if label to be used
     $html = $tpl->fetch('product_details/includes/quantity_box_general.tpl.php');
     return $html;
 }
예제 #9
0
파일: theme.php 프로젝트: noikiy/owaspbwa
 /**
  * Builds a list of all additional images
  *
  * @param int $product_id
  * @param array $images
  * @return string
  */
 function vmlistAdditionalImages($product_id, $images, $title = '', $limit = 1000)
 {
     global $sess;
     $html = '';
     $i = 0;
     foreach ($images as $image) {
         $thumbtag = ps_product::image_tag($image->file_name, 'class="browseProductImage"', 1, 'product', $image->file_image_thumb_width, $image->file_image_thumb_height);
         $fulladdress = $sess->url('index2.php?page=shop.view_images&amp;image_id=' . $image->file_id . '&amp;product_id=' . $product_id . '&amp;pop=1');
         if ($this->get_cfg('useLightBoxImages', 1)) {
             $html .= vmCommonHTML::getLightboxImageLink($image->file_url, $thumbtag, $title ? $title : stripslashes(htmlentities($image->file_title, ENT_QUOTES)), 'product' . $product_id);
         } else {
             $html .= vmPopupLink($fulladdress, $thumbtag, 640, 550);
         }
         $html .= ' ';
         if (++$i > $limit) {
             break;
         }
     }
     return $html;
 }
예제 #10
0
 /**
  * Deletes one Record.
  */
 function delete_record($record_id, &$d)
 {
     global $db;
     $record_id = intval($record_id);
     if ($this->validate_delete($record_id)) {
         $dbu = new ps_db();
         // 	Get the order items and update the stock level
         // to the number before the order was placed
         $q = "SELECT order_status, product_id, product_quantity FROM #__{vm}_order_item WHERE order_id={$record_id}";
         $db->query($q);
         require_once CLASSPATH . 'ps_product.php';
         // Now update each ordered product
         while ($db->next_record()) {
             if (in_array($db->f('order_status'), array('P', 'X', 'R'))) {
                 continue;
             }
             if (ENABLE_DOWNLOADS == '1' && ps_product::is_downloadable($db->f("product_id")) && VM_DOWNLOADABLE_PRODUCTS_KEEP_STOCKLEVEL == '1') {
                 $q = "UPDATE #__{vm}_product  \n\t\t\t\t\t\t\tSET product_sales=product_sales-" . $db->f("product_quantity") . " \n\t\t\t\t\t\tWHERE product_id=" . $db->f("product_id");
                 $dbu->query($q);
             } else {
                 $q = "UPDATE #__{vm}_product \n\t\t\t\t\t\tSET product_in_stock=product_in_stock+" . $db->f("product_quantity") . ",\n\t\t\t\t\t\t\tproduct_sales=product_sales-" . $db->f("product_quantity") . " \n\t\t\t\t\t\tWHERE product_id=" . $db->f("product_id");
                 $dbu->query($q);
             }
         }
         $q = "DELETE from #__{vm}_orders where order_id='{$record_id}'";
         $db->query($q);
         $q = "DELETE from #__{vm}_order_item where order_id='{$record_id}'";
         $db->query($q);
         $q = "DELETE from #__{vm}_order_payment where order_id='{$record_id}'";
         $db->query($q);
         $q = "DELETE from #__{vm}_product_download where order_id='{$record_id}'";
         $db->query($q);
         $q = "DELETE from #__{vm}_order_history where order_id='{$record_id}'";
         $db->query($q);
         $q = "DELETE from #__{vm}_order_user_info where order_id='{$record_id}'";
         $db->query($q);
         $q = "DELETE FROM #__{vm}_shipping_label where order_id={$record_id}";
         $db->query($q);
         return True;
     } else {
         return False;
     }
 }
예제 #11
0
 function change_product_item_price()
 {
     require_once CLASSPATH . 'ps_product.php';
     global $VM_LANG, $vmLogger, $mosConfig_offset;
     $ps_product = new ps_product();
     $order_item_id = vmGet($_REQUEST, 'order_item_id');
     $product_item_price_new = trim(vmGet($_REQUEST, 'product_item_price'));
     $product_final_price_new = trim(vmGet($_REQUEST, 'product_final_price'));
     $db = new ps_DB();
     // Added, to read user_info_id
     $q = "SELECT user_info_id, product_id, product_quantity, product_final_price, product_item_price, product_final_price - product_item_price AS item_tax ";
     $q .= "FROM #__{vm}_order_item WHERE order_id = '" . $this->order_id . "' ";
     $q .= "AND order_item_id = '" . addslashes($order_item_id) . "'";
     $db->query($q);
     $db->next_record();
     $product_id = $db->f('product_id');
     $timestamp = time() + $mosConfig_offset * 60 * 60;
     $user_info_id = $db->f('user_info_id');
     $prod_weight = $ps_product->get_weight($product_id);
     $my_taxrate = $ps_product->get_product_taxrate($product_id, $prod_weight, $user_info_id);
     $product_item_price = $db->f('product_item_price');
     $product_final_price = $db->f('product_final_price');
     $quantity = $db->f('product_quantity');
     if (is_numeric($product_item_price_new)) {
         $product_final_price_new = round($product_item_price_new * ($my_taxrate + 1), 2);
     }
     $product_item_price_new = $product_final_price_new / ($my_taxrate + 1);
     $q = "UPDATE #__{vm}_order_item ";
     $q .= "SET product_item_price = " . $product_item_price_new . ", ";
     $q .= "product_final_price = " . $product_final_price_new . ", ";
     $q .= "mdate = " . $timestamp . " ";
     $q .= "WHERE order_item_id = '" . addslashes($order_item_id) . "'";
     $db->query($q);
     $db->next_record();
     $this->recalc_order($this->order_id);
     $this->reload_from_db = 1;
     $vmLogger->info($VM_LANG->_('PHPSHOP_ORDER_PRINT_PRICE') . $VM_LANG->_('PHPSHOP_ORDER_EDIT_SOMETHING_HAS_CHANGED'));
 }
예제 #12
0
 /** 
  * Handles special task selectors for pages
  * like the product list
  */
 function LISTS_SPECIAL_TASKS($page)
 {
     global $mosConfig_live_site, $VM_LANG, $product_id;
     $bar =& vmToolBar::getInstance('virtuemart');
     switch ($page) {
         case "product.product_list":
             if (empty($_REQUEST['product_parent_id'])) {
                 // add new attribute
                 $alt = $VM_LANG->_('PHPSHOP_ATTRIBUTE_FORM_MNU');
                 $bar->custom('new', "product.product_attribute_form", 'new', $alt);
             }
             // Go to Price list
             $alt = $VM_LANG->_('PHPSHOP_PRICE_LIST_MNU');
             $bar->custom('new', "product.product_price_list", 'new', $alt);
             // add product type
             $alt = $VM_LANG->_('PHPSHOP_PRODUCT_PRODUCT_TYPE_FORM_MNU');
             $bar->custom('new', "product.product_product_type_form", 'new', $alt);
             /*** Adding an item is only pssible, if the product has attributes ***/
             if (ps_product::product_has_attributes($product_id)) {
                 // Add Item
                 $alt = $VM_LANG->_('PHPSHOP_PRODUCT_FORM_NEW_ITEM_LBL');
                 $bar->custom('new', "product.product_child_form", 'new', $alt);
             }
             $bar->divider();
             if (!empty($_REQUEST['category_id'])) {
                 $alt = $VM_LANG->_('VM_PRODUCTS_MOVE_TOOLBAR');
                 $bar->custom('move', 'product.product_move', 'move', $alt);
                 $bar->divider();
             }
             break;
         case "admin.country_list":
             $alt = $VM_LANG->_('PHPSHOP_ADD_STATE');
             $bar->custom('new', "admin.country_state_form", 'new', $alt);
             $alt = $VM_LANG->_('PHPSHOP_LIST_STATES');
             $bar->custom('new', "admin.country_state_list", 'new', $alt);
             $bar->divider();
             break;
     }
 }
예제 #13
0
?>
<div class="vmRecent">
<?php 
echo $recent_products;
?>
</div>
<?php 
// Show Featured Products
if ($this->get_cfg('showFeatured', 1)) {
    /* featuredproducts(random, no_of_products,category_based) no_of_products 0 = all else numeric amount
       edit featuredproduct.tpl.php to edit layout */
    echo $ps_product->featuredProducts(true, 10, false);
}
// Show Latest Products
if ($this->get_cfg('showlatest', 1)) {
    /* latestproducts(random, no_of_products,month_based,category_based) no_of_products 0 = all else numeric amount
       edit latestproduct.tpl.php to edit layout */
    ps_product::latestProducts(true, 10, false, false);
}
?>

<?php 
if (isset($paypalLogo)) {
    ?>
<div class="vmRecent" style="padding: 10px; text-align: center;">
	<?php 
    echo $paypalLogo;
    ?>
</div>
<?php 
}
예제 #14
0
파일: dhl.php 프로젝트: noikiy/owaspbwa
 function get_insurance_value($pid)
 {
     /* Read current Configuration */
     require_once CLASSPATH . "shipping/" . __CLASS__ . ".cfg.php";
     $db = new ps_DB();
     /* XXX map shopper group 'DUTY' to sgid (shopper group id) */
     $q = "SELECT shopper_group_id FROM #__{vm}_shopper_group ";
     $q .= "WHERE shopper_group_name='" . DHL_INSURANCE_SHOPPER_GROUP . "'";
     $db->query($q);
     if (!$db->next_record()) {
         /* no group was specific for insurnace value, use normal price */
         $ps_product = new ps_product();
         $p_array = $ps_product->get_price($pid);
         $duty_value = $p_array['product_price'];
     } else {
         $sgid = $db->f("shopper_group_id");
         $q = "SELECT product_price FROM #__{vm}_product_price ";
         $q .= "WHERE product_id='" . $pid . "' ";
         $q .= "AND shopper_group_id='" . $sgid . "'";
         $db->query($q);
         if ($db->next_record()) {
             $duty_value = $db->f("product_price");
         } else {
             /* use the default product price */
             $ps_product = new ps_product();
             $p_array = $ps_product->get_price($pid);
             $duty_value = $p_array['product_price'];
         }
     }
     return $duty_value;
 }
 /**
  * Display Product Data
  */
 function displayScroller(&$rows)
 {
     global $mosConfig_absolute_path;
     $database = new ps_DB();
     require_once CLASSPATH . "ps_product.php";
     $ps_product = new ps_product();
     $cnt = 0;
     if ($this->ScrollCSSOverride == 'yes') {
         $txt_size = $this->ScrollTextSize . 'px';
         $margin = $this->ScrollMargin . 'px';
         //$height=($height-intval($margin+0));
         //$width=($width-intval($margin+30));
         echo $this->params->get('pretext', "");
         echo " <div style=\"text-align:" . $this->ScrollAlign . ";background-color: " . $this->ScrollBGColor . "; width:" . $this->ScrollWidth . "px;\n                       margin-top: {$margin}; margin-right: {$margin}; margin-bottom: {$margin}; margin-left: {$margin};\" >\n               <marquee behavior=\"" . $this->ScrollBehavior . "\" \n                        direction=\"" . $this->ScrollDirection . "\"  \n                        height=\"" . $this->ScrollHeight . "\"\n                        width=\"" . $this->ScrollWidth . "\"\n                        scrollamount=\"" . $this->ScrollAmount . "\"\n                        scrolldelay=\"" . $this->ScrollDelay . "\"\n                        truespeed=\"true\" onmouseover=\"this.stop()\" onmouseout=\"this.start()\"\n                        style=\"text-align: " . $this->ScrollTextAlign . "; color: " . $this->ScrollTextColor . "; font-weight: " . $this->ScrollTextWeight . "; font-size: {$txt_size};\" >";
     } else {
         echo " <div style=\"width:" . $this->ScrollWidth . "px;text-align:" . $this->ScrollAlign . ";\">\n               <marquee behavior=\"" . $this->ScrollBehavior . "\" \n                        direction=\"" . $this->ScrollDirection . "\"  \n                        height=\"" . $this->ScrollHeight . "\"\n                        width=\"" . $this->ScrollWidth . "\"\n                        scrollamount=\"" . $this->ScrollAmount . "\"\n                        scrolldelay=\"" . $this->ScrollDelay . "\"\n                        truespeed=\"true\" onmouseover=\"this.stop()\" onmouseout=\"this.start()\">";
     }
     $show_product_name = $this->show_product_name == "yes" ? true : false;
     $show_addtocart = $this->show_addtocart == "yes" ? true : false;
     $show_price = $this->show_price == "yes" ? true : false;
     if ($this->ScrollDirection == 'left' || $this->ScrollDirection == 'right') {
         echo '<table border="0"><tr>';
     }
     foreach ($rows as $row) {
         if ($this->ScrollDirection == 'left' || $this->ScrollDirection == 'right') {
             echo '<td style="vertical-align:top;padding: 2px 5px 2px 5px;">';
         }
         $ps_product->show_snapshot($row->product_sku, $show_price, $show_addtocart, $show_product_name);
         if ($this->ScrollDirection == 'left' || $this->ScrollDirection == 'right') {
             echo '</td>';
         } else {
             for ($i = 0; $i < $this->ScrollLineCharTimes; $i++) {
                 echo $this->ScrollLineChar;
             }
         }
     }
     if ($this->ScrollDirection == 'left' || $this->ScrollDirection == 'right') {
         echo '</tr></table>';
     }
     echo "    </marquee>\n            </div>";
 }
예제 #16
0
 function getCartnvpstr(&$order_totals = array())
 {
     global $auth, $VM_LANG;
     $cart = $_SESSION['cart'];
     require_once CLASSPATH . 'ps_product.php';
     $ps_product = new ps_product();
     $ret_str = "";
     $item_total = 0;
     for ($i = 0; $i < $cart["idx"]; $i++) {
         // Product PRICE
         $price = $ps_product->get_adjusted_attribute_price($cart[$i]["product_id"], $cart[$i]["description"]);
         // Convert to product currency if necessary
         $product_price = $GLOBALS['CURRENCY']->convert($price["product_price"], $price["product_currency"]);
         // SUBTOTAL CALCULATION
         $ret_str .= "&L_AMT" . $i . "=" . round($product_price, 2);
         $ret_str .= "&L_QTY" . $i . "=" . $cart[$i]["quantity"];
         $ret_str .= "&L_NAME" . $i . "=" . urlencode($ps_product->get_field($_SESSION['cart'][$i]["product_id"], "product_name"));
         $item_total += round($product_price, 2) * $cart[$i]["quantity"];
     }
     if (!empty($order_totals['coupon_discount'])) {
         // Discount is the difference left after order total has been reduced by subtotal, tax, shipping and shipping tax
         $discount = round($order_totals['order_total'], 2) - $item_total - round($order_totals['order_tax'], 2) - $order_totals['order_shipping'] - $order_totals['order_shipping_tax'];
         // add discount as line item
         $ret_str .= "&L_AMT" . $i . "=" . round($discount, 2);
         $ret_str .= "&L_QTY" . $i . "=1";
         $ret_str .= "&L_NAME" . $i . "=" . urlencode($VM_LANG->_('PHPSHOP_COUPON_DISCOUNT'));
         $item_total += $discount;
     }
     $order_totals['item_total'] = round($item_total, 2);
     $ret_str .= "&ITEMAMT=" . round($item_total, 2);
     //die( $ret_str );
     return $ret_str;
 }
예제 #17
0
 function list_attribute($product_id, $fils = true)
 {
     global $VM_LANG, $CURRENCY_DISPLAY;
     $ps_product = new ps_product();
     $db = new ps_DB();
     $db_sku = new ps_DB();
     $db_item = new ps_DB();
     // Get list of children
     if ($fils) {
         $q = "SELECT product_id,product_name FROM #__{vm}_product WHERE product_parent_id='{$product_id}' AND product_publish='Y'";
     } else {
         $q = "SELECT product_parent_id FROM #__{vm}_product WHERE product_id='{$product_id}'";
         $db->setQuery($q);
         $db->query();
         $db->next_record();
         $product_parent_id = $db->f("product_parent_id");
         $q = "SELECT product_id,product_name FROM #__{vm}_product WHERE product_parent_id='{$product_parent_id}' AND product_publish='Y'";
     }
     $db->setQuery($q);
     $db->query();
     if ($db->num_rows() > 0) {
         $display = '<select name="product_id" onChange="this.form.add_product_validate.value=0;this.form.submit();">';
         $display .= '<option value="-1">Choisissez un produit item</option>';
         while ($db->next_record()) {
             $display .= '<option value="' . $db->f("product_id") . '"';
             if ($product_id == $db->f("product_id")) {
                 $display .= ' selected="yes"';
             }
             $display .= '>' . $db->f("product_name");
             // For each child get attribute values by looping through attribute list
             $q = "SELECT product_id, attribute_name FROM #__{vm}_product_attribute_sku ";
             $q .= "WHERE product_id='{$product_id}' ORDER BY attribute_list ASC";
             $db_sku->setQuery($q);
             $db_sku->query();
             while ($db_sku->next_record()) {
                 $q = "SELECT attribute_name, attribute_value, product_id ";
                 $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()) {
                     $display .= ' - ' . $db_item->f("attribute_name") . " ";
                     $display .= "(" . $db_item->f("attribute_value") . ")";
                     if (!$db_sku->is_last_record()) {
                         $display .= '; ';
                     }
                 }
             }
             // Attributes for this item are done.
             // Now get item price
             $price = $ps_product->get_price($db->f("product_id"));
             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;
             }
             $display .= ' - ' . $CURRENCY_DISPLAY->getFullValue($price["product_price"]);
             $display .= '</option>';
         }
         $display .= '</select>';
     } else {
         $display = "<input type=\"hidden\" name=\"product_id\" value=\"{$product_id}\" />\n";
     }
     return $display;
 }
			<?php 
    echo $featured['product_price'];
    ?>
<br />
            <?php 
    if ($featured["product_thumb"]) {
        ?>
                <a title="<?php 
        echo $featured["product_name"];
        ?>
" href="<?php 
        $sess->purl(URL . "index.php?option=com_virtuemart&amp;page=shop.product_details&amp;flypage=" . $featured["flypage"] . "&amp;product_id=" . $featured["product_id"]);
        ?>
"> 
				<?php 
        echo ps_product::image_tag($featured["product_thumb"], "class=\"browseProductImage\" border=\"0\" alt=\"" . $featured["product_name"] . "\"");
        ?>
</a><br /><br/>
            <?php 
    }
    ?>
            <?php 
    echo $featured['product_s_desc'];
    ?>
<br />
            
            <?php 
    echo $featured['form_addtocart'];
    ?>
	</div>
	<?php 
?>

<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>
예제 #20
0
	
	<td align="center" width="<?php 
    echo $cellwidth;
    ?>
%" >
		<br />
         <a title="<?php 
    echo $category["category_name"];
    ?>
" href="<?php 
    $sess->purl(URL . "index.php?option=com_virtuemart&amp;page=shop.browse&amp;category_id=" . $category["category_id"]);
    ?>
"> 
			<?php 
    if ($category["category_thumb_image"]) {
        echo ps_product::image_tag($category["category_thumb_image"], "alt=\"" . $category["category_name"] . "\"", 0, "category");
        echo "<br /><br/>\n";
    }
    echo $category["category_name"];
    echo $category['number_of_products'];
    ?>
		 </a><br/>
	</td>
	
	
	<?php 
    // Do we need to close the current row now?
    if ($iCol == $categories_per_row) {
        // If the number of products per row has been reached
        echo "</tr>\n";
        $iCol = 1;
}
// Display Style
if (empty($products_per_row)) {
    $products_per_row = $params->get('products_per_row', 4);
}
// Display X products per Row
if (empty($show_price)) {
    $show_price = (bool) $params->get('show_price', 1);
}
// Display the Product Price?
if (empty($show_addtocart)) {
    $show_addtocart = (bool) $params->get('show_addtocart', 1);
}
// Display the "Add-to-Cart" Link?
require_once CLASSPATH . 'ps_product.php';
$ps_product = new ps_product();
$db = new ps_DB();
if ($category_id) {
    $q = "SELECT DISTINCT product_sku FROM #__{vm}_product, #__{vm}_product_category_xref, #__{vm}_category WHERE ";
    $q .= "product_parent_id=''";
    $q .= "AND #__{vm}_product.product_id=#__{vm}_product_category_xref.product_id ";
    $q .= "AND #__{vm}_category.category_id=#__{vm}_product_category_xref.category_id ";
    $q .= "AND #__{vm}_category.category_id='{$category_id}'";
    $q .= "AND #__{vm}_product.product_publish='Y' ";
    if (CHECK_STOCK && PSHOP_SHOW_OUT_OF_STOCK_PRODUCTS != "1") {
        $q .= " AND product_in_stock > 0 ";
    }
    $q .= "ORDER BY product_name DESC";
} else {
    $q = "SELECT DISTINCT product_sku FROM #__{vm}_product WHERE ";
    $q .= "product_parent_id='' AND vendor_id='" . $_SESSION['ps_vendor_id'] . "' ";
예제 #22
0
            }
            ?>
			  <tr class="<?php 
            echo $bgcolor;
            ?>
" valign="top">
          <?php 
            $ps_order_change_html->html_change_delete_item($dbt->f("order_item_id"));
            ?>
          <?php 
            $ps_order_change_html->html_change_item_quantity($dbt->f("order_item_id"), $dbt->f("product_quantity"));
            ?>
        <td width="30%" align="left">
				<?php 
            $dbt->p("order_item_name");
            echo "<br /><span style=\"font-size: smaller;\">" . ps_product::getDescriptionWithTax($dbt->f("product_attribute")) . "</span>";
            if ($downloadable) {
                echo '<br /><br />
  			  			<div style="font-weight:bold;">' . $VM_LANG->_('VM_DOWNLOAD_STATS') . '</div>';
                if (empty($files)) {
                    echo '<em>- ' . $VM_LANG->_('VM_DOWNLOAD_NOTHING_LEFT') . ' -</em>';
                    $enable_download_function = $ps_function->get_function('insertDownloadsForProduct');
                    if ($perm->check($enable_download_function['perms'])) {
                        echo '<form action="' . $_SERVER['PHP_SELF'] . '" method="post">				  		
  			  			<input type="hidden" name="page" value="' . $page . '" />
  			  			<input type="hidden" name="order_id" value="' . $order_id . '" />
  			  			<input type="hidden" name="product_id" value="' . $dbt->f('product_id') . '" />
  			  			<input type="hidden" name="user_id" value="' . $db->f('user_id') . '" />
  			  			<input type="hidden" name="func" value="insertDownloadsForProduct" />
  						  <input type="hidden" name="vmtoken" value="' . vmSpoofValue($sess->getSessionId()) . '" />
  			  			<input type="hidden" name="option" value="' . $option . '" />
예제 #23
0
* @version $Id: ro_basket.php 1906 2009-09-26 14:57:52Z soeren_nb $
* @package VirtueMart
* @subpackage html
* @copyright Copyright (C) 2004-2009 soeren - All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* VirtueMart is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See /administrator/components/com_virtuemart/COPYRIGHT.php for copyright notices and details.
*
* http://virtuemart.net
*/
mm_showMyFileName(__FILE__);
require_once CLASSPATH . 'ps_product.php';
$ps_product = new ps_product();
require_once CLASSPATH . 'ps_checkout.php';
$ps_checkout = new ps_checkout();
require_once CLASSPATH . 'ps_shipping_method.php';
global $weight_total, $total, $tax_total, $order_tax_details, $discount_factor, $order_total;
/* make sure this is the checkout screen */
if ($cart["idx"] == 0) {
    echo $VM_LANG->_('PHPSHOP_EMPTY_CART');
    $checkout = False;
} else {
    $checkout = True;
    $payment_method_id = vmGet($_REQUEST, "payment_method_id");
    $total = 0;
    // Added for the zone shipping module
    $vars["zone_qty"] = 0;
    $weight_total = 0;
예제 #24
0
 /** 
  * Handles special task selectors for pages
  * like the product list
  */
 function LISTS_SPECIAL_TASKS($page)
 {
     global $mosConfig_live_site, $VM_LANG, $product_id, $vmIcons;
     switch ($page) {
         case "product.product_list":
             if (empty($_REQUEST['product_parent_id'])) {
                 // add new attribute
                 $alt = "&nbsp;" . $VM_LANG->_('PHPSHOP_ATTRIBUTE_FORM_MNU');
                 vmMenuBar::custom("", "product.product_attribute_form", $vmIcons['new_icon'], $vmIcons['new_icon2'], $alt);
                 vmMenuBar::spacer();
             }
             // Go to Price list
             $alt = "&nbsp;" . $VM_LANG->_('PHPSHOP_PRICE_LIST_MNU');
             vmMenuBar::custom("", "product.product_price_list", $vmIcons['new_icon'], $vmIcons['new_icon2'], $alt);
             vmMenuBar::spacer();
             // add product type
             $alt = "&nbsp;" . $VM_LANG->_('PHPSHOP_PRODUCT_PRODUCT_TYPE_FORM_MNU');
             vmMenuBar::custom("", "product.product_product_type_form", $vmIcons['new_icon'], $vmIcons['new_icon2'], $alt);
             vmMenuBar::spacer();
             /*** Adding an item is only pssible, if the product has attributes ***/
             if (ps_product::product_has_attributes($product_id)) {
                 // Add Item
                 $alt = "&nbsp;" . $VM_LANG->_('PHPSHOP_PRODUCT_FORM_NEW_ITEM_LBL');
                 vmMenuBar::custom("", "product.product_child_form", $vmIcons['new_icon'], $vmIcons['new_icon2'], $alt);
             }
             vmMenuBar::divider();
             vmMenuBar::spacer();
             if (!empty($_REQUEST['category_id'])) {
                 $alt = $VM_LANG->_('VM_PRODUCTS_MOVE_TOOLBAR');
                 vmMenuBar::custom('move', 'product.product_move', $mosConfig_live_site . '/administrator/images/move.png', $mosConfig_live_site . '/administrator/images/move_f2.png', $alt);
                 vmMenuBar::spacer();
                 vmMenuBar::divider();
                 vmMenuBar::spacer();
             }
             break;
         case "admin.country_list":
             $alt = "&nbsp;" . $VM_LANG->_('PHPSHOP_ADD_STATE');
             vmMenuBar::custom("", "admin.country_state_form", $vmIcons['new_icon'], $vmIcons['new_icon2'], $alt);
             vmMenuBar::spacer();
             $alt = "&nbsp;" . $VM_LANG->_('PHPSHOP_LIST_STATES');
             vmMenuBar::custom("", "admin.country_state_list", $vmIcons['new_icon'], $vmIcons['new_icon2'], $alt);
             vmMenuBar::spacer();
             vmMenuBar::divider();
             vmMenuBar::spacer();
             break;
         default:
     }
 }
예제 #25
0
 /**
  * Calculate the tax charges for the current order.
  * You can switch the way, taxes are calculated:
  * either based on the VENDOR address,
  * or based on the ship-to address.
  * ! Creates the global $order_tax_details
  *
  * @param float $order_taxable
  * @param array $d
  * @return float
  */
 function calc_order_tax($order_taxable, $d)
 {
     global $order_tax_details, $discount_factor;
     $total = 0;
     $order_tax = 0;
     $auth = $_SESSION['auth'];
     $ps_vendor_id = $_SESSION["ps_vendor_id"];
     $db = new ps_DB();
     $ship_to_info_id = vmGet($_REQUEST, 'ship_to_info_id');
     require_once CLASSPATH . 'ps_tax.php';
     $ps_tax = new ps_tax();
     $discount_factor = 1;
     // Shipping address based TAX
     if (!ps_checkout::tax_based_on_vendor_address()) {
         $q = "SELECT state, country FROM #__{vm}_user_info ";
         $q .= "WHERE user_info_id='" . $ship_to_info_id . "'";
         $db->query($q);
         $db->next_record();
         $state = $db->f("state");
         $country = $db->f("country");
         $q = "SELECT * FROM #__{vm}_tax_rate WHERE tax_country='{$country}' ";
         if (!empty($state)) {
             $q .= "AND (tax_state='{$state}' OR tax_state=' {$state} ')";
         }
         $db->query($q);
         if ($db->next_record()) {
             $rate = $order_taxable * floatval($db->f("tax_rate"));
             if (empty($rate)) {
                 $order_tax = 0.0;
             } else {
                 $cart = $_SESSION['cart'];
                 $order_tax = 0.0;
                 if ((!empty($_SESSION['coupon_discount']) || !empty($d['payment_discount'])) && PAYMENT_DISCOUNT_BEFORE == '1') {
                     require_once CLASSPATH . 'ps_product.php';
                     $ps_product = new ps_product();
                     for ($i = 0; $i < $cart["idx"]; $i++) {
                         $item_weight = ps_shipping_method::get_weight($cart[$i]["product_id"]) * $cart[$i]['quantity'];
                         if ($item_weight != 0 or TAX_VIRTUAL) {
                             $price = $ps_product->get_adjusted_attribute_price($cart[$i]["product_id"], $cart[$i]["description"]);
                             $price['product_price'] = $GLOBALS['CURRENCY']->convert($price['product_price'], $price['product_currency']);
                             $tax_rate = $db->f("tax_rate");
                             $use_coupon_discount = @$_SESSION['coupon_discount'];
                             //if( !empty( $_SESSION['coupon_discount'] )) {
                             //    if( $auth["show_price_including_tax"] == 1 ) {
                             //        $use_coupon_discount = $_SESSION['coupon_discount'] / ($tax_rate+1);
                             //    }
                             //}
                             $factor = 100 * ($use_coupon_discount + @$d['payment_discount']) / $this->_subtotal;
                             $price["product_price"] = $price["product_price"] - $factor * $price["product_price"] / 100;
                             @($order_tax_details[$tax_rate] += $price["product_price"] * $tax_rate * $cart[$i]["quantity"]);
                             $order_tax += $price["product_price"] * $tax_rate * $cart[$i]["quantity"];
                             $total += $price["product_price"] * $cart[$i]["quantity"];
                         } else {
                             $order_tax += 0.0;
                         }
                     }
                 } else {
                     $order_tax = $rate;
                 }
             }
         } else {
             $order_tax = 0.0;
         }
         $order_tax_details[$db->f('tax_rate')] = $order_tax;
     } else {
         // Calculate the Tax with a tax rate for every product
         $cart = $_SESSION['cart'];
         $order_tax = 0.0;
         $total = 0.0;
         if ((!empty($_SESSION['coupon_discount']) || !empty($d['payment_discount'])) && PAYMENT_DISCOUNT_BEFORE == '1') {
             // We need to recalculate the tax details when the discounts are applied
             // BEFORE taxes - because they affect the product subtotals then
             $order_tax_details = array();
         }
         require_once CLASSPATH . 'ps_product.php';
         $ps_product = new ps_product();
         require_once CLASSPATH . 'ps_shipping_method.php';
         for ($i = 0; $i < $cart["idx"]; $i++) {
             $item_weight = ps_shipping_method::get_weight($cart[$i]["product_id"]) * $cart[$i]['quantity'];
             if ($item_weight != 0 or TAX_VIRTUAL) {
                 $price = $ps_product->get_adjusted_attribute_price($cart[$i]["product_id"], $cart[$i]["description"]);
                 $price['product_price'] = $GLOBALS['CURRENCY']->convert($price['product_price'], $price['product_currency']);
                 $tax_rate = $ps_product->get_product_taxrate($cart[$i]["product_id"]);
                 if ((!empty($_SESSION['coupon_discount']) || !empty($d['payment_discount'])) && PAYMENT_DISCOUNT_BEFORE == '1') {
                     $use_coupon_discount = @$_SESSION['coupon_discount'];
                     if (!empty($_SESSION['coupon_discount'])) {
                         if ($auth["show_price_including_tax"] == 1) {
                             $use_coupon_discount = $_SESSION['coupon_discount'] / ($tax_rate + 1);
                         }
                     }
                     $factor = 100 * ($use_coupon_discount + @$d['payment_discount']) / $this->_subtotal;
                     $price["product_price"] = $price["product_price"] - $factor * $price["product_price"] / 100;
                     @($order_tax_details[$tax_rate] += $price["product_price"] * $tax_rate * $cart[$i]["quantity"]);
                 }
                 $order_tax += $price["product_price"] * $tax_rate * $cart[$i]["quantity"];
                 $total += $price["product_price"] * $cart[$i]["quantity"];
             }
         }
         if ((!empty($_SESSION['coupon_discount']) || !empty($d['payment_discount'])) && PAYMENT_DISCOUNT_BEFORE != '1') {
             // Here we need to re-calculate the Discount
             // because we assume the Discount is "including Tax"
             $discounted_total = @$d['order_subtotal_withtax'] - @$_SESSION['coupon_discount'] - @$d['payment_discount'];
             if ($discounted_total != @$d['order_subtotal_withtax'] && @$d['order_subtotal_withtax'] > 0.0) {
                 $discount_factor = $discounted_total / $d['order_subtotal_withtax'];
                 foreach ($order_tax_details as $rate => $value) {
                     $order_tax_details[$rate] = $value * $discount_factor;
                 }
             }
         }
         if (is_object($this->_SHIPPING)) {
             $taxrate = $this->_SHIPPING->get_tax_rate();
             if ($taxrate) {
                 $rate = $this->_SHIPPING->get_rate($d);
                 if ($auth["show_price_including_tax"] == 1) {
                     @($order_tax_details[$taxrate] += $rate - $rate / ($taxrate + 1));
                 } else {
                     @($order_tax_details[$taxrate] += $rate * $taxrate);
                 }
             }
         }
     }
     return round($order_tax, 2);
 }
// Load the virtuemart main parse code
if( file_exists(dirname(__FILE__).'/../../components/com_virtuemart/virtuemart_parser.php' )) {
	require_once( dirname(__FILE__).'/../../components/com_virtuemart/virtuemart_parser.php' );
} else {
	require_once( dirname(__FILE__).'/../components/com_virtuemart/virtuemart_parser.php' );
}

$max_items = $params->get( 'max_items', 2 ); //maximum number of items to display
$category_id = $params->get( 'category_id', null ); // Display products from this category only
$display_style = $params->get( 'display_style', "vertical" ); // Display Style
$products_per_row = $params->get( 'products_per_row', 4 ); // Display X products per Row
$show_price = (bool)$params->get( 'show_price', 1 ); // Display the Product Price?
$show_addtocart = (bool)$params->get( 'show_addtocart', 1 ); // Display the "Add-to-Cart" Link?

require_once ( CLASSPATH. 'ps_product.php');
$ps_product = new ps_product;
$db = new ps_DB;
global $short_desc;
global $desc;

if ( $category_id ) {
	// BEGIN - MultiCategory Display - deneb
	$cat_ids = explode(",",$category_id);
	if (count($cat_ids) > 1){
		$multi_cats = 1;
	}
	// END - MultiCategory Display - deneb

	$q  = "SELECT DISTINCT product_sku, product_desc, product_s_desc FROM #__{vm}_product, #__{vm}_product_category_xref, #__{vm}_category WHERE \n";
	$q .= "(#__{vm}_product.product_parent_id='' OR #__{vm}_product.product_parent_id='0') \n";
	$q .= "AND #__{vm}_product.product_id=#__{vm}_product_category_xref.product_id \n";
    /**
     * This is the main function which stores the order information in the database
     * 
     * @author Ashish Solanki!
     * @return boolean
     */
    function updateRecords($order_number, $order_total, &$d)
    {
        require_once CLASSPATH . 'ps_checkout.php';
        $ps_chkout = new ps_checkout();
        global $order_tax_details, $afid, $VM_LANG, $auth, $my, $mosConfig_offset, $vmLogger, $vmInputFilter, $discount_factor;
        $ps_vendor_id = $_SESSION["ps_vendor_id"];
        $cart = $_SESSION['cart'];
        require_once CLASSPATH . 'ps_payment_method.php';
        $ps_payment_method = new ps_payment_method();
        require_once CLASSPATH . 'ps_product.php';
        $ps_product = new ps_product();
        require_once CLASSPATH . 'ps_cart.php';
        $ps_cart = new ps_cart();
        $db = new ps_DB();
        $totals = $ps_chkout->calc_order_totals($d);
        extract($totals);
        $timestamp = time();
        //Custom
        $vmLogger->debug('-- Checkout Debug--
							Subtotal: ' . $order_subtotal . '
							Taxable: ' . $order_taxable . '
							Payment Discount: ' . $payment_discount . '
							Coupon Discount: ' . $coupon_discount . '
							Shipping: ' . $order_shipping . '
							Shipping Tax : ' . $order_shipping_tax . '
							Tax : ' . $order_tax . '
							------------------------
							Order Total: ' . $order_total . '
							----------------------------');
        // Check to see if Payment Class File exists
        $payment_class = $ps_payment_method->get_field($d["payment_method_id"], "payment_class");
        $d['new_order_status'] = 'P';
        // This is meant to be updated by a payment modules' process_payment method
        if (!class_exists($payment_class)) {
            include CLASSPATH . "payment/{$payment_class}.php";
        }
        $_PAYMENT = new $payment_class();
        // Remove the Coupon, because it is a Gift Coupon and now is used!!
        if (@$_SESSION['coupon_type'] == "gift") {
            $d['coupon_id'] = $_SESSION['coupon_id'];
            include_once CLASSPATH . 'ps_coupon.php';
            ps_coupon::remove_coupon_code($d);
        }
        // Get the IP Address
        if (!empty($_SERVER['REMOTE_ADDR'])) {
            $ip = $_SERVER['REMOTE_ADDR'];
        } else {
            $ip = 'unknown';
        }
        // Collect all fields and values to store them!
        $fields = array('user_id' => $auth["user_id"], 'vendor_id' => $ps_vendor_id, 'order_number' => $order_number, 'user_info_id' => $d["ship_to_info_id"], 'ship_method_id' => @urldecode($d["shipping_rate_id"]), 'order_total' => $order_total, 'order_subtotal' => $order_subtotal, 'order_tax' => $order_tax, 'order_tax_details' => serialize($order_tax_details), 'order_shipping' => $order_shipping, 'order_shipping_tax' => $order_shipping_tax, 'order_discount' => $payment_discount, 'coupon_discount' => $coupon_discount, 'coupon_code' => @$_SESSION['coupon_code'], 'order_currency' => $GLOBALS['product_currency'], 'order_status' => 'P', 'cdate' => $timestamp, 'mdate' => $timestamp, 'customer_note' => htmlspecialchars(vmRequest::getString('customer_note', '', 'POST', 'none'), ENT_QUOTES), 'ip_address' => $ip);
        // Insert the main order information
        $db->buildQuery('INSERT', '#__{vm}_orders', $fields);
        $result = $db->query();
        $d["order_id"] = $order_id = $db->last_insert_id();
        if ($result === false || empty($order_id)) {
            $vmLogger->crit('Adding the Order into the Database failed! User ID: ' . $auth["user_id"]);
            return false;
        }
        // Insert the initial Order History.
        $mysqlDatetime = date("Y-m-d G:i:s", $timestamp);
        $fields = array('order_id' => $order_id, 'order_status_code' => 'P', 'date_added' => $mysqlDatetime, 'customer_notified' => 1, 'comments' => '');
        $db->buildQuery('INSERT', '#__{vm}_order_history', $fields);
        $db->query();
        /**
         * Insert the Order payment info 
         */
        $payment_number = str_replace(array(' ', '|', '-'), '', @$_SESSION['ccdata']['order_payment_number']);
        $d["order_payment_code"] = @$_SESSION['ccdata']['credit_card_code'];
        // Payment number is encrypted using mySQL encryption functions.
        $fields = array('order_id' => $order_id, 'payment_method_id' => $d["payment_method_id"], 'order_payment_log' => @$d["order_payment_log"], 'order_payment_trans_id' => $vmInputFilter->safeSQL(@$d["order_payment_trans_id"]));
        if (!empty($payment_number) && VM_STORE_CREDITCARD_DATA == '1') {
            // Store Credit Card Information only if the Store Owner has decided to do so
            $fields['order_payment_code'] = $d["order_payment_code"];
            $fields['order_payment_expire'] = @$_SESSION["ccdata"]["order_payment_expire"];
            $fields['order_payment_name'] = @$_SESSION["ccdata"]["order_payment_name"];
            $fields['order_payment_number'] = VM_ENCRYPT_FUNCTION . "( '{$payment_number}','" . ENCODE_KEY . "')";
            $specialfield = array('order_payment_number');
        } else {
            $specialfield = array();
        }
        $db->buildQuery('INSERT', '#__{vm}_order_payment', $fields, '', $specialfield);
        $db->query();
        /**
         * Insert the User Billto & Shipto Info
         */
        // First: get all the fields from the user field list to copy them from user_info into the order_user_info
        $fields = array();
        require_once CLASSPATH . 'ps_userfield.php';
        $userfields = ps_userfield::getUserFields('', false, '', true, true);
        foreach ($userfields as $field) {
            if ($field->name == 'email') {
                $fields[] = 'user_email';
            } else {
                $fields[] = $field->name;
            }
        }
        $fieldstr = implode(',', $fields);
        // Save current Bill To Address
        $q = "INSERT INTO `#__{vm}_order_user_info` \n\t\t\t(`order_info_id`,`order_id`,`user_id`,address_type, " . $fieldstr . ") ";
        $q .= "SELECT NULL, '{$order_id}', '" . $auth['user_id'] . "', address_type, " . $fieldstr . " FROM #__{vm}_user_info WHERE user_id='" . $auth['user_id'] . "' AND address_type='BT'";
        $db->query($q);
        // Save current Ship to Address if applicable
        $q = "INSERT INTO `#__{vm}_order_user_info` \n\t\t\t(`order_info_id`,`order_id`,`user_id`,address_type, " . $fieldstr . ") ";
        $q .= "SELECT NULL, '{$order_id}', '" . $auth['user_id'] . "', address_type, " . $fieldstr . " FROM #__{vm}_user_info WHERE user_id='" . $auth['user_id'] . "' AND user_info_id='" . $d['ship_to_info_id'] . "' AND address_type='ST'";
        $db->query($q);
        /**
         * Insert all Products from the Cart into order line items; 
         * one row per product in the cart 
         */
        $dboi = new ps_DB();
        for ($i = 0; $i < $cart["idx"]; $i++) {
            $r = "SELECT product_id,product_in_stock,product_sales,product_parent_id,product_sku,product_name ";
            $r .= "FROM #__{vm}_product WHERE product_id='" . $cart[$i]["product_id"] . "'";
            $dboi->query($r);
            $dboi->next_record();
            $product_price_arr = $ps_product->get_adjusted_attribute_price($cart[$i]["product_id"], $cart[$i]["description"]);
            $product_price = $GLOBALS['CURRENCY']->convert($product_price_arr["product_price"], $product_price_arr["product_currency"]);
            if (empty($_SESSION['product_sess'][$cart[$i]["product_id"]]['tax_rate'])) {
                $my_taxrate = $ps_product->get_product_taxrate($cart[$i]["product_id"]);
            } else {
                $my_taxrate = $_SESSION['product_sess'][$cart[$i]["product_id"]]['tax_rate'];
            }
            // Attribute handling
            $product_parent_id = $dboi->f('product_parent_id');
            $description = '';
            if ($product_parent_id > 0) {
                $db_atts = $ps_product->attribute_sql($dboi->f('product_id'), $product_parent_id);
                while ($db_atts->next_record()) {
                    $description .= $db_atts->f('attribute_name') . ': ' . $db_atts->f('attribute_value') . '; ';
                }
            }
            $description .= $ps_product->getDescriptionWithTax($_SESSION['cart'][$i]["description"], $dboi->f('product_id'));
            $product_final_price = round($product_price * ($my_taxrate + 1), 2);
            $vendor_id = $ps_vendor_id;
            $fields = array('order_id' => $order_id, 'user_info_id' => $d["ship_to_info_id"], 'vendor_id' => $vendor_id, 'product_id' => $cart[$i]["product_id"], 'order_item_sku' => $dboi->f("product_sku"), 'order_item_name' => $dboi->f("product_name"), 'product_quantity' => $cart[$i]["quantity"], 'product_item_price' => $product_price, 'product_final_price' => $product_final_price, 'order_item_currency' => $GLOBALS['product_currency'], 'order_status' => 'P', 'product_attribute' => $description, 'cdate' => $timestamp, 'mdate' => $timestamp);
            $db->buildQuery('INSERT', '#__{vm}_order_item', $fields);
            $db->query();
            // Update Stock Level and Product Sales, decrease - no matter if in stock or not!
            $q = "UPDATE #__{vm}_product ";
            $q .= "SET product_in_stock = product_in_stock - " . (int) $cart[$i]["quantity"];
            $q .= " WHERE product_id = '" . $cart[$i]["product_id"] . "'";
            $db->query($q);
            $q = "UPDATE #__{vm}_product ";
            $q .= "SET product_sales= product_sales + " . (int) $cart[$i]["quantity"];
            $q .= " WHERE product_id='" . $cart[$i]["product_id"] . "'";
            $db->query($q);
            // Update stock of parent product, if all child products are sold, thanks Ragnar Brynjulfsson
            if ($dboi->f("product_parent_id") != 0) {
                $q = "SELECT COUNT(product_id) ";
                $q .= "FROM #__{vm}_product ";
                $q .= "WHERE product_parent_id = " . $dboi->f("product_parent_id");
                $q .= " AND product_in_stock > 0";
                $db->query($q);
                $db->next_record();
                if (!$db->f("COUNT(product_id)")) {
                    $q = "UPDATE #__{vm}_product ";
                    $q .= "SET product_in_stock = 0 ";
                    $q .= "WHERE product_id = " . $dboi->f("product_parent_id") . " LIMIT 1";
                    $db->query($q);
                }
            }
        }
        ######## BEGIN DOWNLOAD MOD ###############
        if (ENABLE_DOWNLOADS == "1") {
            require_once CLASSPATH . 'ps_order.php';
            for ($i = 0; $i < $cart["idx"]; $i++) {
                // only handle downloadable products here
                if (ps_product::is_downloadable($cart[$i]["product_id"])) {
                    $params = array('product_id' => $cart[$i]["product_id"], 'order_id' => $order_id, 'user_id' => $auth["user_id"]);
                    ps_order::insert_downloads_for_product($params);
                    if (@VM_DOWNLOADABLE_PRODUCTS_KEEP_STOCKLEVEL == '1') {
                        // Update the product stock level back to where it was.
                        $q = "UPDATE #__{vm}_product ";
                        $q .= "SET product_in_stock = product_in_stock + " . (int) $cart[$i]["quantity"];
                        $q .= " WHERE product_id = '" . (int) $cart[$i]["product_id"] . "'";
                        $db->query($q);
                    }
                }
            }
        }
        ################## END DOWNLOAD MOD ###########
        // Export the order_id so the checkout complete page can get it
        $d["order_id"] = $order_id;
        /*
         * Let the shipping module know which shipping method
         * was selected.  This way it can save any information
         * it might need later to print a shipping label.
         */
        if (is_callable(array($this->_SHIPPING, 'save_rate_info'))) {
            $this->_SHIPPING->save_rate_info($d);
        }
        // Now as everything else has been done, we can update the Order Status
        $update_order = false;
        if ($order_total == 0.0) {
            // code moved out of $_PAYMENT check as no payment will be needed when $order_total=0.0
            // If the Order Total is zero, we can confirm the order to automatically enable the download
            $d['order_status'] = ENABLE_DOWNLOAD_STATUS;
            $update_order = true;
        } elseif (isset($_PAYMENT)) {
            if ($d['new_order_status'] != 'P') {
                $d['order_status'] = $d['new_order_status'];
                $update_order = true;
            }
        }
        if ($update_order) {
            require_once CLASSPATH . "ps_order.php";
            $ps_order = new ps_order();
            $ps_order->order_status_update($d);
        }
        // Send the e-mail confirmation messages
        $ps_chkout->email_receipt($order_id);
        // Reset the cart (=empty it)
        $ps_cart->reset();
        $_SESSION['savedcart']['idx'] = 0;
        $ps_cart->saveCart();
        // Unset the payment_method variables
        $d["payment_method_id"] = "";
        $d["order_payment_number"] = "";
        $d["order_payment_expire"] = "";
        $d["order_payment_name"] = "";
        $d["credit_card_code"] = "";
        // Clear the sensitive Session data
        $_SESSION['ccdata']['order_payment_name'] = "";
        $_SESSION['ccdata']['order_payment_number'] = "";
        $_SESSION['ccdata']['order_payment_expire_month'] = "";
        $_SESSION['ccdata']['order_payment_expire_year'] = "";
        $_SESSION['ccdata']['credit_card_code'] = "";
        $_SESSION['coupon_discount'] = "";
        $_SESSION['coupon_id'] = "";
        $_SESSION['coupon_redeemed'] = false;
        $_POST["payment_method_id"] = "";
        $_POST["order_payment_number"] = "";
        $_POST["order_payment_expire"] = "";
        $_POST["order_payment_name"] = "";
        $_SESSION['order_id'] = $order_id;
    }
예제 #28
0
 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;
 }
예제 #29
0
echo $row->title;
?>
"><?php 
echo $row->title;
?>
</a> </h3>
  <div class="ice-vmimagearea">
    <p><?php 
echo ps_product::image_tag($row->product_thumb_image, "alt=\"" . $row->product_name . "\"");
?>
</p>
    <span class="ice-pprice">
    <?php 
global $iceps_product;
if (!$iceps_product) {
    $iceps_product = new ps_product();
}
echo $iceps_product->show_price($row->product_id, true, false);
?>
    </span>
    <?php 
if (!trim(ps_product::product_has_attributes($row->product_id, true))) {
    ?>
    <div class="ice-addtocart">
      <form action="<?php 
    echo $row->addtocart_link;
    ?>
" method="post" name="addtocart" id="addtocart<?php 
    echo $row->product_id;
    ?>
" onsubmit="handleAddToCart( this.id );return false;" >
예제 #30
0
// Creates a new HTML_Table object that will help us
// to build a table holding all the products
$table = new HTML_Table('width="100%"');
$table->addRow($tableheader, 'class="sectiontableheader"', 'th', true);
foreach ($products as $product) {
    foreach ($product as $attr => $val) {
        // Using this we make all the variables available in the template
        // translated example: $this->set( 'product_name', $product_name );
        $this->set($attr, $val);
    }
    $data[$row][] = '<a href="' . $product['product_flypage'] . '" title="' . $product['product_name'] . '">' . $product['product_name'] . '</a>';
    $data[$row][] = $product['product_sku'];
    if (_SHOW_PRICES && $auth['show_prices']) {
        $data[$row][] = $product['product_price'];
    }
    $data[$row][] = '<a href="' . $product['product_flypage'] . '" title="' . $product['product_name'] . '">' . ps_product::image_tag($product['product_thumb_image']) . '</a>';
    $data[$row][] = $product['product_s_desc'];
    if ($product['has_addtocart']) {
        $data[$row][] = $product['form_addtocart'];
    } else {
        $data[$row][] = '<a href="' . $product['product_flypage'] . '" title="' . $product['product_name'] . '">' . $product['product_details'] . '</a>';
    }
    $row++;
}
// Loop through each row and build the table
foreach ($data as $key => $value) {
    $table->addRow($data[$key], 'class="sectiontableentry' . $i . '"', 'td', true);
    $i = $i == 1 ? 2 : 1;
}
// Display the table
echo $table->toHtml();