function b_myshop_new_show($options) { // '10|0'; // Display 10 products from all categories or specify category id global $xoopsConfig, $xoopsTpl; include XOOPS_ROOT_PATH . '/modules/myshop/include/common.php'; $block = $products = array(); $start = 0; $limit = $options[0]; $categoryId = $options[1]; // $myshop_shelf_parameters->resetDefaultValues()->setProductsType('product_online')->setStart($start)->setLimit($limit)->setSort('product_submitted')->setOrder('DESC')->setCategory($categoryId); $myshop_shelf_parameters->resetDefaultValues()->setProductsType('recent')->setStart($start)->setLimit($limit)->setSort('product_submitted DESC, product_title')->setOrder('ASC')->setCategory($categoryId); $products = $myshop_shelf->getProducts($myshop_shelf_parameters); if (isset($products['lastTitle'])) { unset($products['lastTitle']); } if (count($products) > 0) { $url = MYSHOP_URL . 'include/myshop.css'; $block['nostock_msg'] = myshop_utils::getModuleOption('nostock_msg'); $block['block_products'] = $products; // $xoopsTpl->assign("xoops_module_header", "<link rel=\"stylesheet\" type=\"text/css\" href=\"$url\" />"); return $block; } else { return false; } }
/** * Random Display x products(s) */ function b_myshop_random_show($options) { // '10|0|0'; // Display 10 products from all categories or specify category id, this monthly only? global $xoopsConfig, $xoopsTpl; include XOOPS_ROOT_PATH . '/modules/myshop/include/common.php'; $products = $block = array(); $start = 0; $limit = $options[0]; $categoryId = $options[1]; $thisMonthOnly = intval($options[2]); $myshop_shelf_parameters->resetDefaultValues()->setProductsType('random')->setStart($start)->setLimit($limit)->setSort('RAND()')->setCategory($categoryId)->setThisMonthOnly($thisMonthOnly); $products = $myshop_shelf->getProducts($myshop_shelf_parameters); if (isset($products['lastTitle'])) { unset($products['lastTitle']); } if (count($products) > 0) { $url = MYSHOP_URL . 'include/myshop.css'; $block['nostock_msg'] = myshop_utils::getModuleOption('nostock_msg'); $block['block_products'] = $products; $xoopsTpl->assign("xoops_module_header", "<link rel=\"stylesheet\" type=\"text/css\" href=\"{$url}\" />"); return $block; } else { return false; } }
function listCart() { global $xoopsTpl, $uid; $cartForTemplate = $discountsDescription = array(); $emptyCart = false; $shippingAmount = $commandAmount = $vatAmount = $commandAmountTTC = $discountsCount = 0; $goOn = ''; $reductions = new myshop_reductions(); $reductions->computeCart($cartForTemplate, $emptyCart, $shippingAmount, $commandAmount, $vatAmount, $goOn, $commandAmountTTC, $discountsDescription, $discountsCount); $myshop_Currency =& myshop_Currency::getInstance(); $xoopsTpl->assign('emptyCart', $emptyCart); // Empty $xoopsTpl->assign('caddieProducts', $cartForTemplate); // Products $xoopsTpl->assign('shippingAmount', $myshop_Currency->amountForDisplay($shippingAmount)); $xoopsTpl->assign('commandAmount', $myshop_Currency->amountForDisplay($commandAmount)); $xoopsTpl->assign('vatAmount', $myshop_Currency->amountForDisplay($vatAmount)); $xoopsTpl->assign('discountsCount', $discountsCount); $xoopsTpl->assign('goOn', $goOn); $xoopsTpl->assign('commandAmountTTC', $myshop_Currency->amountForDisplay($commandAmountTTC, 'l')); $xoopsTpl->assign('discountsDescription', $discountsDescription); $showOrderButton = true; if (xoops_trim(myshop_utils::getModuleOption('paypal_email')) == '' && myshop_utils::getModuleOption('offline_payment') == 0) { $showOrderButton = false; } $showRegistredOnly = false; if (myshop_utils::getModuleOption('restrict_orders', false) && $uid == 0) { $showRegistredOnly = true; $showOrderButton = false; } $xoopsTpl->assign('showRegistredOnly', $showRegistredOnly); $xoopsTpl->assign('showOrderButton', $showOrderButton); }
/** * Return URL to access category according to module preferences * * @return string URL */ function getLink() { $url = ''; if (myshop_utils::getModuleOption('urlrewriting') == 1) { // URL rewriting $url = MYSHOP_URL . 'category-' . $this->getVar('cat_cid') . myshop_utils::makeSeoUrl($this->getVar('cat_title')) . '.html'; } else { $url = MYSHOP_URL . 'category.php?cat_cid=' . $this->getVar('cat_cid'); } return $url; }
function __construct() { // Get the module's preferences $this->_decimalsCount = myshop_utils::getModuleOption('decimals_count'); $this->_thousandsSep = myshop_utils::getModuleOption('thousands_sep'); $this->_decimalSep = myshop_utils::getModuleOption('decimal_sep'); $this->_moneyFull = myshop_utils::getModuleOption('money_full'); $this->_moneyShort = myshop_utils::getModuleOption('money_short'); $this->_monnaiePlace = myshop_utils::getModuleOption('monnaie_place'); $this->_thousandsSep = str_replace('[space]', ' ', $this->_thousandsSep); $this->_decimalSep = str_replace('[space]', ' ', $this->_decimalSep); }
function b_myshop_new_show($options) { // '10|0'; // Display 10 products from all categories or specify category id global $xoopsConfig, $xoopsTpl; include XOOPS_ROOT_PATH . '/modules/myshop/include/common.php'; $tblLivres = $tblCategories = $tblTmp = $tbl_tmp_vat = $tbl_vat = $tbl_tmp_lang = $block = $tbl_books_id = array(); $tblLivres = $h_myshop_products->getRecentProducts(0, $options[0], $options[1]); if (count($tblLivres) > 0) { $url = MYSHOP_URL . 'myshop.css'; $block['nostock_msg'] = myshop_utils::getModuleOption('nostock_msg'); return $block; } else { return false; } }
function b_myshop_rated_show($options) { // '10|0'; // Display 10 products from all categories or specify category id global $xoopsConfig, $xoopsTpl; include XOOPS_ROOT_PATH . '/modules/myshop/include/common.php'; $products = $block = array(); $start = 0; $limit = $options[0]; $categoryId = $options[1]; $myshop_shelf_parameters->resetDefaultValues()->setProductsType('bestrated')->setStart($start)->setLimit($limit)->setSort('product_rating')->setOrder('DESC')->setCategory($categoryId); $products = $myshop_shelf->getProducts($myshop_shelf_parameters); if (isset($products['lastTitle'])) { unset($products['lastTitle']); } if (count($products) > 0) { $url = MYSHOP_URL . 'include/myshop.css'; $block['nostock_msg'] = myshop_utils::getModuleOption('nostock_msg'); $block['block_products'] = $products; return $block; } else { return false; } }
/** * block to display items in cart * * @param integer $options[0] Count of items to show (0 = no limit) * @return array Block's content */ function b_myshop_cart_show($options) { global $mod_pref, $xoopsConfig; include XOOPS_ROOT_PATH . '/modules/myshop/include/common.php'; $productsCount = intval($options[0]); $cartForTemplate = $block = array(); $emptyCart = false; $shippingAmount = $commandAmount = $vatAmount = $discountsCount = 0; $goOn = ''; $commandAmountTTC = 0; $discountsDescription = array(); // Calculate Amount $reductions = new myshop_reductions(); $reductions->computeCart($cartForTemplate, $emptyCart, $shippingAmount, $commandAmount, $vatAmount, $goOn, $commandAmountTTC, $discountsDescription, $discountsCount); $dec = myshop_utils::getModuleOption('decimals_count'); if ($emptyCart) { return ''; } $block['block_money_full'] = myshop_utils::getModuleOption('money_full'); $block['block_money_short'] = myshop_utils::getModuleOption('money_short'); $block['block_shippingAmount'] = sprintf("%0." . $dec . 'f', $shippingAmount); // Shipping $block['block_commandAmount'] = sprintf("%0." . $dec . 'f', $commandAmount); // Without Fee $block['block_vatAmount'] = sprintf("%0." . $dec . 'f', $vatAmount); // Vat $block['block_commandAmountTTC'] = sprintf("%0." . $dec . 'f', $commandAmountTTC); // ALL Fee $block['block_discountsDescription'] = $discountsDescription; // Discount if ($productsCount > 0 && count($cartForTemplate) > $productsCount) { array_slice($cartForTemplate, 0, $productsCount - 1); } $block['block_caddieProducts'] = $cartForTemplate; // Products in cart return $block; }
function b_myshop_category_show($options) { global $xoopsTpl; $block = array(); include XOOPS_ROOT_PATH . '/modules/myshop/include/common.php'; $url = MYSHOP_URL . 'include/myshop.css'; $xoopsTpl->assign("xoops_module_header", "<link rel=\"stylesheet\" type=\"text/css\" href=\"{$url}\" />"); $block['nostock_msg'] = myshop_utils::getModuleOption('nostock_msg'); if (intval($options[0]) == 0) { $block['block_option'] = 0; if (!isset($GLOBALS['current_category']) || $GLOBALS['current_category'] == -1) { return false; } $cat_cid = intval($GLOBALS['current_category']); include XOOPS_ROOT_PATH . '/modules/myshop/include/common.php'; if ($cat_cid > 0) { include_once XOOPS_ROOT_PATH . '/class/tree.php'; $tbl_categories = $tblChilds = $tbl_tmp = array(); $tbl_categories = $h_myshop_cat->getAllCategories(); $mytree = new XoopsObjectTree($tbl_categories, 'cat_cid', 'cat_pid'); $tblChilds = $mytree->getAllChild($cat_cid); foreach ($tblChilds as $item) { $tbl_tmp[] = "<a href='" . $item->getLink() . "' title='" . myshop_utils::makeHrefTitle($item->getVar('cat_title')) . "'>" . $item->getVar('cat_title') . "</a>"; } $block['block_categories'] = $tbl_tmp; $category = null; if ($cat_cid > 0) { $category = $h_myshop_cat->get($cat_cid); if (is_object($category)) { $block['block_current_category'] = $category->toArray(); } } } else { $tbl_categories = array(); $criteria = new Criteria('cat_pid', 0, '='); $criteria->setSort('cat_title'); $tbl_categories = $h_myshop_cat->getObjects($criteria, true); foreach ($tbl_categories as $item) { $tbl_tmp[] = "<a href='" . $item->getLink() . "' title='" . myshop_utils::makeHrefTitle($item->getVar('cat_title')) . "'>" . $item->getVar('cat_title') . "</a>"; } $block['block_categories'] = $tbl_tmp; } } else { // Normal display $block['block_option'] = 1; include XOOPS_ROOT_PATH . '/modules/myshop/include/common.php'; include_once MYSHOP_PATH . 'class/tree.php'; $tbl_categories = $h_myshop_cat->getAllCategories(); $mytree = new Myshop_XoopsObjectTree($tbl_categories, 'cat_cid', 'cat_pid'); $jump = MYSHOP_URL . "category.php?cat_cid="; $additional = "onchange='location=\"" . $jump . "\"+this.options[this.selectedIndex].value'"; if (isset($GLOBALS['current_category']) && $GLOBALS['current_category'] != -1) { $cat_cid = intval($GLOBALS['current_category']); } else { $cat_cid = 0; } $htmlSelect = $mytree->makeSelBox('cat_cid', 'cat_title', '-', $cat_cid, false, 0, $additional); $block['htmlSelect'] = $htmlSelect; } return $block; }
* Inde page with last products */ require 'header.php'; $GLOBALS['current_category'] = -1; $xoopsOption['template_main'] = 'myshop_index.html'; require_once XOOPS_ROOT_PATH . '/header.php'; require_once MYSHOP_PATH . 'class/registryfile.php'; // Initialize $start = isset($_GET['start']) ? intval($_GET['start']) : 0; $limit = myshop_utils::getModuleOption('newproducts'); // Max number to display $baseurl = MYSHOP_URL . basename(__FILE__); // Script URL $registry = new myshop_registryfile(); // Template options $xoopsTpl->assign('nostock_msg', myshop_utils::getModuleOption('nostock_msg')); $xoopsTpl->assign('mod_pref', $mod_pref); $xoopsTpl->assign('welcome_msg', nl2br($registry->getfile(MYSHOP_TEXTFILE1))); // VAT $vatArray = $h_myshop_vat->getAllVats(); // Products $xoopsTpl->assign('total_products_count', sprintf(_MYSHOP_THEREARE, $h_myshop_products->getTotalPublishedProductsCount())); if ($limit > 0) { $itemsCount = $h_myshop_products->getRecentProductsCount(); if ($itemsCount > $limit) { require_once XOOPS_ROOT_PATH . '/class/pagenav.php'; $pagenav = new XoopsPageNav($itemsCount, $limit, $start); $xoopsTpl->assign('pagenav', $pagenav->renderNav()); } $myshop_shelf_parameters->resetDefaultValues()->setProductsType('recent')->setStart($start)->setLimit($limit)->setSort('product_submitted DESC, product_title')->setWithXoopsUser(true)->setWithRelatedProducts(true); $products = $myshop_shelf->getProducts($myshop_shelf_parameters);
$item->unsetNew(); $add = false; } else { $item = $h_myshop_cat->create(true); $add = true; } $opRedirect = 'categories'; $item->setVars($_POST); if (isset($_POST['delpicture']) && intval($_POST['delpicture']) == 1) { $item->deletePicture(); } $destname = ''; $res1 = myshop_utils::uploadFile(0, MYSHOP_PICTURES_PATH); if ($res1 === true) { if (myshop_utils::getModuleOption('resize_others')) { myshop_utils::resizePicture(MYSHOP_PICTURES_PATH . DIRECTORY_SEPARATOR . $destname, MYSHOP_PICTURES_PATH . DIRECTORY_SEPARATOR . $destname, myshop_utils::getModuleOption('images_width'), myshop_utils::getModuleOption('images_height'), true); } $item->setVar('cat_imgurl', basename($destname)); } else { if ($res1 !== false) { echo $res1; } } $res = $h_myshop_cat->insert($item); if ($res) { myshop_utils::updateCache(); if ($add) { $notification_handler =& xoops_gethandler('notification'); $tags['CATEGORY_NAME'] = $item->getVar('cat_title'); $tags['CATEGORY_URL'] = MYSHOP_URL . 'category.php?cat_cid=' . $item->getVar('cat_cid'); $tags['X_MODULE_URL'] = MYSHOP_URL;
/** * Retourne l'url à utiliser pour accéder à la page d'un fabricant * * @return string */ function getLink() { $url = ''; if (myshop_utils::getModuleOption('urlrewriting') == 1) { // On utilise l'url rewriting $url = MYSHOP_URL . 'manufacturer-' . $this->getVar('manu_id') . myshop_utils::makeSeoUrl($this->getVar('manu_commercialname') . ' ' . $this->getVar('manu_name')) . '.html'; } else { // Pas d'utilisation de l'url rewriting $url = MYSHOP_URL . 'manufacturer.php?manu_id=' . $this->getVar('manu_id'); } return $url; }
function getProductSelector($label, $showAll = true, $sort = 'product_title', $order = 'ASC') { include_once XOOPS_ROOT_PATH . "/class/xoopsformloader.php"; $criteria = new CriteriaCompo(); $criteria->add(new Criteria('product_id', 0, '<>')); if (!$showAll) { if (myshop_utils::getModuleOption('show_unpublished') == 0) { // Ne pas afficher les produits qui ne sont pas publiés $criteria->add(new Criteria('product_submitted', time(), '<=')); } if (myshop_utils::getModuleOption('nostock_display') == 0) { // Se limiter aux seuls produits encore en stock $criteria->add(new Criteria('product_stock', 0, '>')); } } $start = isset($_GET['startProduct']) ? intval($_GET['startProduct']) : 0; $criteria->setSort($sort); $criteria->setOrder($order); $itemsCount = $this->getCount($criteria); if ($itemsCount > MYSHOP_MAX_PRODUCTS) { include_once XOOPS_ROOT_PATH . '/class/pagenav.php'; $pagenav = new XoopsPageNav($itemsCount, MYSHOP_MAX_PRODUCTS, $start, 'startProduct'); } $productTray = new XoopsFormElementTray($label, '<br />'); $products = $this->getObjects($criteria); foreach ($products as $product) { $relatedProducts_d[$oneitem->getVar('product_id')] = xoops_trim($oneitem->getVar('product_title')); } $user_select_nav = new XoopsFormLabel('', $nav->renderNav(4)); $criteria->setStart($start); $criteria->setLimit(MYSHOP_MAX_PRODUCTS); }
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true); // set document information $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor(PDF_AUTHOR); $pdf->SetTitle($doc_title); $pdf->SetSubject($doc_subject); $pdf->SetKeywords($doc_keywords); $firstLine = utf8_encode(myshop_utils::getModuleName() . ' - ' . $xoopsConfig['sitename']); $secondLine = MYSHOP_URL . ' - ' . formatTimestamp(time(), 'm'); $pdf->SetHeaderData('', '', $firstLine, $secondLine); //set margins $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); //set auto page breaks $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); //set image scale factor $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); $pdf->setLanguageArray($l); //set language items //initialize document $pdf->AliasNbPages(); $pdf->AddPage(); $pdf->writeHTML($content1, true, 0); if (myshop_utils::getModuleOption('use_price')) { $pdf->AddPage(); $pdf->writeHTML($content2, true, 0); } $pdf->Output();
$xoopsTpl->assign('pagenav', ''); } // Breadcrumb $ancestors = $mytree->getAllParent($cat_cid); $ancestors = array_reverse($ancestors); $tbl_tmp[] = "<a href='" . MYSHOP_URL . "index.php' title='" . myshop_utils::makeHrefTitle(myshop_utils::getModuleName()) . "'>" . myshop_utils::getModuleName() . '</a>'; foreach ($ancestors as $item) { $tbl_tmp[] = "<a href='" . $item->getLink() . "' title='" . myshop_utils::makeHrefTitle($item->getVar('cat_title')) . "'>" . $item->getVar('cat_title') . '</a>'; } // Add current category $tbl_tmp[] = "<a href='" . $category->getLink() . "' title='" . myshop_utils::makeHrefTitle($category->getVar('cat_title')) . "'>" . $category->getVar('cat_title') . '</a>'; $breadcrumb = implode(' » ', $tbl_tmp); $xoopsTpl->assign('breadcrumb', $breadcrumb); // Meta $title = strip_tags($breadcrumb); if (!myshop_utils::getModuleOption('manual_meta')) { myshop_utils::setMetas($title, $title, str_replace('»', ',', $title)); } else { $pageTitle = xoops_trim($category->getVar('cat_metatitle')) == '' ? $title : $category->getVar('cat_metatitle'); $metaDescription = xoops_trim($category->getVar('cat_metadescription')) != '' ? $category->getVar('cat_metadescription') : $title; $metaKeywords = xoops_trim($category->getVar('cat_metakeywords')); myshop_utils::setMetas($pageTitle, $metaDescription, $metaKeywords); } // Products Data $products = array(); $myshop_shelf_parameters->resetDefaultValues()->setProductsType('recent')->setCategory($cat_cid)->setStart($start)->setLimit($limit)->setSort('product_submitted DESC, product_title'); $products = $myshop_shelf->getProducts($myshop_shelf_parameters); if (count($products) > 0) { if (isset($products['lastTitle'])) { unset($products['lastTitle']); }
$myts =& MyTextSanitizer::getInstance(); // handlers $h_myshop_manufacturer = $myshop_handlers->h_myshop_manufacturer; $h_myshop_products = $myshop_handlers->h_myshop_products; $h_myshop_productsmanu = $myshop_handlers->h_myshop_productsmanu; $h_myshop_caddy = $myshop_handlers->h_myshop_caddy; $h_myshop_cat = $myshop_handlers->h_myshop_cat; $h_myshop_commands = $myshop_handlers->h_myshop_commands; $h_myshop_related = $myshop_handlers->h_myshop_related; $h_myshop_vat = $myshop_handlers->h_myshop_vat; $h_myshop_votedata = $myshop_handlers->h_myshop_votedata; $h_myshop_discounts = $myshop_handlers->h_myshop_discounts; $h_myshop_stores = $myshop_handlers->h_myshop_stores; $h_myshop_files = $myshop_handlers->h_myshop_files; $h_myshop_persistent_cart = $myshop_handlers->h_myshop_persistent_cart; $myshop_shelf = new myshop_shelf(); // Front $myshop_shelf_parameters = new myshop_shelf_parameters(); // Images if (!defined("_MYSHOP_EDIT")) { global $xoopsConfig; if (file_exists(MYSHOP_PATH . 'language/' . $xoopsConfig['language'] . '/main.php')) { include MYSHOP_PATH . 'language/' . $xoopsConfig['language'] . '/main.php'; } else { include MYSHOP_PATH . 'language/english/main.php'; } } $icones = array('edit' => "<img src='" . MYSHOP_IMAGES_URL . "edit.png' alt='" . _MYSHOP_EDIT . "' align='middle' />", 'delete' => "<img src='" . MYSHOP_IMAGES_URL . "delete.png' alt='" . _MYSHOP_DELETE . "' align='middle' />", 'online' => "<img src='" . MYSHOP_IMAGES_URL . "online.png' alt='" . _MYSHOP_ONLINE . "' align='middle' />", 'offline' => "<img src='" . MYSHOP_IMAGES_URL . "offline.png' alt='" . _MYSHOP_OFFLINE . "' align='middle' />", 'ok' => "<img src='" . MYSHOP_IMAGES_URL . "ok.png' alt='" . _MYSHOP_VALIDATE_COMMAND . "' align='middle' />", 'copy' => "<img src='" . MYSHOP_IMAGES_URL . "duplicate.png' alt='" . _MYSHOP_DUPLICATE_PRODUCT . "' align='middle' />", 'details' => "<img src='" . MYSHOP_IMAGES_URL . "details.png' alt='" . _MYSHOP_DETAILS . "' align='middle' />"); // settings $mod_pref = array('money_short' => myshop_utils::getModuleOption('money_short'), 'money_full' => myshop_utils::getModuleOption('money_full'), 'url_rewriting' => myshop_utils::getModuleOption('urlrewriting'), 'tooltip' => myshop_utils::getModuleOption('infotips'), 'advertisement' => myshop_utils::getModuleOption('advertisement'), 'rss' => myshop_utils::getModuleOption('use_rss'), 'nostock_msg' => myshop_utils::getModuleOption('nostock_msg'), 'use_price' => myshop_utils::getModuleOption('use_price'), 'restrict_orders' => myshop_utils::getModuleOption('restrict_orders'), 'isAdmin' => myshop_utils::isAdmin());
function myshop_search($queryarray, $andor, $limit, $offset, $userid) { global $xoopsDB; require XOOPS_ROOT_PATH . '/modules/myshop/include/common.php'; require_once XOOPS_ROOT_PATH . '/modules/myshop/class/myshop_products.php'; // Products Search $sql = 'SELECT product_id, product_title, product_submitted, product_submitter FROM ' . $xoopsDB->prefix('myshop_products') . ' WHERE (product_online = 1'; if (myshop_utils::getModuleOption('show_unpublished') == 0) { $sql .= ' AND product_submitted <= ' . time(); } if (myshop_utils::getModuleOption('nostock_display') == 0) { $sql .= ' AND product_stock > 0'; } if ($userid != 0) { $sql .= ' AND product_submitter = ' . $userid; } $sql .= ') '; $tmpObject = new myshop_products(); $datas = $tmpObject->getVars(); $tblFields = array(); $cnt = 0; foreach ($datas as $key => $value) { if ($value['data_type'] == XOBJ_DTYPE_TXTBOX || $value['data_type'] == XOBJ_DTYPE_TXTAREA) { if ($cnt == 0) { $tblFields[] = $key; } else { $tblFields[] = ' OR ' . $key; } $cnt++; } } $count = count($queryarray); $more = ''; if (is_array($queryarray) && $count > 0) { $cnt = 0; $sql .= ' AND ('; $more = ')'; foreach ($queryarray as $oneQuery) { $sql .= '('; $cond = " LIKE '%" . $oneQuery . "%' "; $sql .= implode($cond, $tblFields) . $cond . ')'; $cnt++; if ($cnt != $count) { $sql .= ' ' . $andor . ' '; } } } $sql .= $more . ' ORDER BY product_submitted DESC'; $i = 0; $ret = array(); $myts =& MyTextSanitizer::getInstance(); $result = $xoopsDB->query($sql, $limit, $offset); while ($myrow = $xoopsDB->fetchArray($result)) { $ret[$i]['image'] = 'images/product.png'; $ret[$i]['link'] = "product.php?product_id=" . $myrow['product_id']; $ret[$i]['title'] = $myts->htmlSpecialChars($myrow['product_title']); $ret[$i]['time'] = $myrow['product_submitted']; $ret[$i]['uid'] = $myrow['product_submitter']; $i++; } return $ret; }
// stores $stores = $h_myshop_stores->getList(); $stores[0] = _ALL; ksort($stores); $xoopsTpl->assign('disc_store_id_options', $stores); $xoopsTpl->assign('disc_store_id_selected', $item->getVar('disc_store_id')); // Category $xoopsTpl->assign('disc_cat_cid_options', $categoriesSelect); // Products $products = $h_myshop_products->getList(); $products[0] = _ALL; ksort($products); $xoopsTpl->assign('disc_product_id_options', $products); $xoopsTpl->assign('disc_product_id_selected', $item->getVar('disc_product_id')); $xoopsTpl->assign('discount', $discountForTemplate); $xoopsTpl->assign('currencyName', myshop_utils::getModuleOption('money_full')); $editor = myshop_utils::getWysiwygForm(_AM_MYSHOP_DISCOUNT_DESCR, 'disc_description', $item->getVar('disc_description', 'e'), 15, 60, 'description_hidden'); $xoopsTpl->assign('editor', $editor->render()); $xoopsTpl->display('db:myshop_admin_discounts.html'); break; case 'copy': xoops_cp_header(); $id = isset($_GET['id']) ? intval($_GET['id']) : 0; if (empty($id)) { myshop_utils::redirect(_AM_MYSHOP_ERROR_1, $baseurl, 5); } $opRedirect = 'discounts'; $item = null; $item = $h_myshop_discounts->get($id); if (is_object($item)) { $newDiscount = $item->xoopsClone();
if (isset($_POST['op'])) { $op = $_POST['op']; } elseif (isset($_GET['op'])) { $op = $_GET['op']; } $action = 'default'; if (isset($_POST['action'])) { $action = $_POST['action']; } elseif (isset($_GET['action'])) { $action = $_GET['action']; } $limit = myshop_utils::getModuleOption('items_count'); $baseurl = MYSHOP_URL . 'admin/' . basename(__FILE__); $conf_msg = myshop_utils::javascriptLinkConfirm(_AM_MYSHOP_CONF_DELITEM); $myshop_Currency =& myshop_Currency::getInstance(); $manual_meta = myshop_utils::getModuleOption('manual_meta'); global $xoopsConfig; if (file_exists(MYSHOP_PATH . 'language/' . $xoopsConfig['language'] . '/modinfo.php')) { require_once MYSHOP_PATH . 'language/' . $xoopsConfig['language'] . '/modinfo.php'; } else { require_once MYSHOP_PATH . 'language/english/modinfo.php'; } if (file_exists(MYSHOP_PATH . 'language/' . $xoopsConfig['language'] . '/main.php')) { require_once MYSHOP_PATH . 'language/' . $xoopsConfig['language'] . '/main.php'; } else { require_once MYSHOP_PATH . 'language/english/main.php'; } if (!is_dir(MYSHOP_CACHE_PATH)) { mkdir(MYSHOP_CACHE_PATH, 0777); file_put_contents(MYSHOP_CACHE_PATH . '/index.html', '<script>history.go(-1);</script>'); }
/** * Last cart of user * @return void */ function reloadPersistentCart() { global $xoopsUser, $h_myshop_persistent_cart; if (myshop_utils::getModuleOption('persistent_cart') == 0) { return false; } if (is_object($xoopsUser)) { $persistent_carts = array(); $persistent_carts = $h_myshop_persistent_cart->getUserProducts(); foreach ($persistent_carts as $persistent_cart) { $this->addProduct($persistent_cart->getVar('persistent_product_id'), $persistent_cart->getVar('persistent_qty')); } } }
/** * Display Media Product */ require 'header.php'; $type = isset($_GET['type']) ? strtolower($_GET['type']) : 'picture'; $product_id = isset($_GET['product_id']) ? intval($_GET['product_id']) : 0; if ($product_id > 0) { $product = null; $product = $h_myshop_products->get($product_id); if (!is_object($product)) { exit(_MYSHOP_ERROR1); } if ($product->getVar('product_online') == 0) { exit(_MYSHOP_ERROR2); } if (myshop_utils::getModuleOption('show_unpublished') == 0 && $product->getVar('product_submitted') > time()) { exit(_MYSHOP_ERROR3); } } else { exit(_ERRORS); } switch ($type) { case 'attachment': $file_id = isset($_GET['file_id']) ? intval($_GET['file_id']) : 0; if ($file_id == 0) { exit(_MYSHOP_ERROR13); } $attachedFile = null; $attachedFile = $h_myshop_files->get($file_id); if (!is_object($attachedFile)) { exit(_MYSHOP_ERROR19);
// 1 = Global Cache, 2 = Individual Cache (by template) $tpl->xoops_setCacheTime(MYSHOP_RSS_CACHE); // Time cache in seconds if (!$tpl->is_cached('db:myshop_rss.html', $cat_cid)) { $categoryTitle = ''; if (!empty($cat_cid)) { $category = null; $category = $h_myshop_cat->get($cat_cid); if (is_object($category)) { $categoryTitle = $category->getVar('cat_title'); } } $sitename = htmlspecialchars($xoopsConfig['sitename'], ENT_QUOTES); $email = checkEmail($xoopsConfig['adminmail'], true); $slogan = htmlspecialchars($xoopsConfig['slogan'], ENT_QUOTES); $limit = myshop_utils::getModuleOption('perpage'); $tpl->assign('charset', $charset); $tpl->assign('channel_title', xoops_utf8_encode($sitename)); $tpl->assign('channel_link', XOOPS_URL . '/'); $tpl->assign('channel_desc', xoops_utf8_encode($slogan)); $tpl->assign('channel_lastbuild', formatTimestamp(time(), 'rss')); $tpl->assign('channel_webmaster', xoops_utf8_encode($email)); $tpl->assign('channel_editor', xoops_utf8_encode($email)); $tpl->assign('channel_category', xoops_utf8_encode($categoryTitle)); $tpl->assign('channel_generator', xoops_utf8_encode(myshop_utils::getModuleName())); $tpl->assign('channel_language', _LANGCODE); $tpl->assign('image_url', XOOPS_URL . '/images/logo.gif'); $dimention = getimagesize(XOOPS_ROOT_PATH . '/images/logo.gif'); if (empty($dimention[0])) { $width = 88; } else {
$sform = new XoopsThemeForm($title, 'frmadd', $baseurl); $sform->setExtra('enctype="multipart/form-data"'); $sform->addElement(new XoopsFormHidden('op', 'files')); $sform->addElement(new XoopsFormHidden('action', 'saveedit')); $sform->addElement(new XoopsFormHidden('file_id', $item->getVar('file_id'))); $file_product_id_select = new XoopsFormSelect(_MYSHOP_PRODUCT, 'file_product_id', $item->getVar('file_product_id', 'e'), 1, false); $file_product_id_select->addOptionArray($products); $sform->addElement($file_product_id_select, true); $sform->addElement(new XoopsFormText(_AM_MYSHOP_DESCRIPTION, 'file_description', 50, 255, $item->getVar('file_description', 'e')), true); if ($op == 'edit' && trim($item->getVar('file_filename')) != '' && $item->fileExists()) { $pictureTray = new XoopsFormElementTray(_AM_MYSHOP_CURRENT_FILE, '<br />'); $pictureTray->addElement(new XoopsFormLabel('', "<a href='" . $item->getURL() . "' target='_blank' />" . $item->getVar('file_filename') . "</a>")); $sform->addElement($pictureTray); unset($pictureTray); } $sform->addElement(new XoopsFormFile(_AM_MYSHOP_FILENAME, 'attachedfile', myshop_utils::getModuleOption('maxuploadsize')), false); $button_tray = new XoopsFormElementTray('', ''); $submit_btn = new XoopsFormButton('', 'post', $label_submit, 'submit'); $button_tray->addElement($submit_btn); $sform->addElement($button_tray); $sform = myshop_utils::formMarkRequiredFields($sform); $sform->display(); break; case 'saveedit': xoops_cp_header(); $id = isset($_POST['file_id']) ? intval($_POST['file_id']) : 0; if (!empty($id)) { $edit = true; $item = $h_myshop_files->get($id); if (!is_object($item)) { myshop_utils::redirect(_AM_MYSHOP_NOT_FOUND, $baseurl, 5);
foreach ($products as $item) { $content = $newsletterTemplate; $tblTmp = $tblTmp2 = array(); $criteria = new CriteriaCompo(); $criteria->add(new Criteria('pm_product_id', $item->getVar('product_id'), '=')); $tblTmp = $h_myshop_productsmanu->getObjects($criteria); foreach ($tblTmp as $productManufacturer) { $tblTmp2[] = $productManufacturer->getVar('pm_manu_id'); } $manufacturers = $h_myshop_manufacturer->getObjects(new Criteria('manu_id', '(' . implode(',', $tblTmp2) . ')', 'IN'), true); $tblTmp = array(); foreach ($manufacturers as $manufacturer) { $tblTmp[] = $manufacturer->getVar('manu_commercialname') . ' ' . $manufacturer->getVar('manu_name'); } $search = array('%title%', '%category%', '%author%', '%published%', '%price%', '%money%', '%hometext%', '%fulltext%', '%discountprice%', '%link%', '%product_sku%', '%product_extraid%', '%product_width%', '%product_date%', '%product_shipping_price%', '%product_stock%', '%product_unitmeasure1%', '%product_weight%', '%product_unitmeasure2%', '%product_download_url%', '%product_length%'); $replace = array($item->getVar('product_title'), $categories[$item->getVar('product_cid')]->getVar('cat_title'), implode(', ', $tblTmp), formatTimestamp($item->getVar('product_submitted'), 's'), myshop_utils::getTTC($item->getVar('product_price'), $vats[$item->getVar('product_vat_id')]->getVar('vat_rate')), myshop_utils::getModuleOption('money_full'), $item->getVar('product_summary'), $item->getVar('product_description'), myshop_utils::getTTC($item->getVar('product_discount_price'), $vats[$item->getVar('product_vat_id')]->getVar('vat_rate')), $item->getLink(), $item->getVar('product_sku'), $item->getVar('product_extraid'), $item->getVar('product_width'), $item->getVar('product_date'), $item->getVar('product_shipping_price'), $item->getVar('product_stock'), $item->getVar('product_unitmeasure1'), $item->getVar('product_weight'), $item->getVar('product_unitmeasure2'), $item->getVar('product_download_url'), $item->getVar('product_length')); $content = str_replace($search, $replace, $content); if ($removeBr) { $content = str_replace('<br />', "\r\n", $content); } if ($removeHtml) { $content = strip_tags($content); } fwrite($fp, $content); } if (xoops_trim($footer) != '') { fwrite($fp, $footer); } fclose($fp); $newsfile = MYSHOP_NEWSLETTER_URL; echo "<a href='{$newsfile}' target='_blank'>" . _AM_MYSHOP_NEWSLETTER_READY . "</a>";
/** * Informe le propriétaire du site qu'une commande à échoué (le paiement) * * @param object $order La commande en question * @return void */ function notifyOrderCanceled(myshop_commands $order) { $msg = array(); $msg['NUM_COMMANDE'] = $order->getVar('cmd_id'); myshop_utils::sendEmailFromTpl('command_shop_cancel.tpl', myshop_utils::getEmailsFromGroup(myshop_utils::getModuleOption('grp_sold')), _MYSHOP_ORDER_CANCELED, $msg); myshop_utils::sendEmailFromTpl('command_client_cancel.tpl', $order->getVar('cmd_email'), _MYSHOP_ORDER_CANCELED, $msg); }
/** * Retourne les produits d'un utilisateur * * @param integer $persistent_uid L'ID de l'utilisateur * @return array Tableaux d'objets de type myshop_persistent_cart */ function getUserProducts($persistent_uid = 0) { if (myshop_utils::getModuleOption('persistent_cart') == 0) { return false; } $persistent_uid = $persistent_uid == 0 ? myshop_utils::getCurrentUserID() : $persistent_uid; $criteria = new Criteria('persistent_uid', $persistent_uid, '='); return $this->getObjects($criteria); }
/** * Categories map */ require 'header.php'; $GLOBALS['current_category'] = -1; $xoopsOption['template_main'] = 'myshop_map.html'; require_once XOOPS_ROOT_PATH . '/header.php'; require_once MYSHOP_PATH . 'class/tree.php'; $xoopsTpl->assign('mod_pref', $mod_pref); $categories = array(); $categories = $h_myshop_cat->getAllCategories(); $mytree = new Myshop_XoopsObjectTree($categories, 'cat_cid', 'cat_pid'); $tree = $mytree->makeTreeAsArray('cat_title', '-'); foreach ($tree as $key => $value) { if (isset($categories[$key])) { $category = $categories[$key]; $xoopsTpl->append('categories', array('cat_url_rewrited' => $category->getLink(), 'cat_href_title' => $category->getHrefTitle(), 'cat_title' => $value)); } } myshop_utils::setCSS(); if (file_exists(MYSHOP_PATH . 'language/' . $xoopsConfig['language'] . '/modinfo.php')) { require_once MYSHOP_PATH . 'language/' . $xoopsConfig['language'] . '/modinfo.php'; } else { require_once MYSHOP_PATH . 'language/english/modinfo.php'; } $xoopsTpl->assign('global_advert', myshop_utils::getModuleOption('advertisement')); $xoopsTpl->assign('breadcrumb', myshop_utils::breadcrumb(array(MYSHOP_URL . basename(__FILE__) => _MI_MYSHOP_SMNAME4))); $title = _MI_MYSHOP_SMNAME4 . ' - ' . myshop_utils::getModuleName(); myshop_utils::setMetas($title, $title); require_once XOOPS_ROOT_PATH . '/footer.php';
/** * Calculate cart order * Content of cart session : * * $datas['number'] = product ref. * $datas['id'] = product id. * $datas['qty'] = quantity * * Private var of $cart is similar + object 'myshop_products' in key 'product' * * @param array $cartForTemplate * @param boolean emptyCart * @param float $shippingAmount * @param float $commandAmount * @param float $vatAmount * @param string $goOn Link to last visited category * @param float $commandAmountTTC Amount with All Fee * @param array $discountsDescription * @param integer $discountsCount */ function computeCart(&$cartForTemplate, &$emptyCart, &$shippingAmount, &$commandAmount, &$vatAmount, &$goOn, &$commandAmountTTC, &$discountsDescription, &$discountsCount) { $emptyCart = false; $goOn = ''; $vats = array(); $cpt = 0; $discountsCount = 0; $this->cart = isset($_SESSION[MyshopMyshop_caddyHandler::CADDY_NAME]) ? $_SESSION[MyshopMyshop_caddyHandler::CADDY_NAME] : array(); $cartCount = count($this->cart); if ($cartCount < 0) { $emptyCart = true; return true; } // Initialize Private Data $this->initializePrivateData(); // Load related products and calculate categories quantity $this->loadProductsAssociatedToCart(); // VAT $vats = $this->handlers->h_myshop_vat->getAllVats(); $myshop_Currency =& myshop_Currency::getInstance(); $caddyCount = count($this->cart); // Initialize total of ht=without VAT, tva= VAT, and shipping $totalHT = $totalVAT = $totalShipping = 0; // Check each product and discount rule foreach ($this->cart as $cartProduct) { if ($cartProduct['product']->getVar('product_discount_price') > 0) { $ht = floatval($cartProduct['product']->getVar('product_discount_price')); } else { $ht = floatval($cartProduct['product']->getVar('product_price')); } $discountedPrice = $ht; $quantity = $cartProduct['qty']; if (myshop_utils::getModuleOption('shipping_quantity')) { $discountedShipping = $cartProduct['product']->getVar('product_shipping_price') * $quantity; } else { $discountedShipping = $cartProduct['product']->getVar('product_shipping_price'); } $totalPrice = 0; $reduction = ''; $cpt++; if ($cpt == $caddyCount) { $category = null; $category = $this->handlers->h_myshop_cat->get($cartProduct['product']->getVar('product_cid')); if (is_object($category)) { $goOn = $category->getLink(); } } // Check All Active Rules foreach ($this->allActiveRules as $rule) { $applyRule = false; if ($rule->disc_group != 0 && myshop_utils::isMemberOfGroup($rule->disc_group) || $rule->disc_group == 0) { if ($rule->disc_cat_cid != 0 && $cartProduct['product']->getVar('product_cid') == $rule->disc_cat_cid || $rule->disc_cat_cid == 0) { if ($rule->disc_store_id != 0 && $cartProduct['product']->getVar('disc_store_id') == $rule->disc_store_id || $rule->disc_store_id == 0) { if ($rule->disc_product_id != 0 && $cartProduct['product']->getVar('product_id') == $rule->disc_product_id || $rule->disc_product_id == 0) { // When to apply switch ($rule->disc_price_case) { case MYSHOP_DISCOUNT_PRICE_CASE_ALL: // All $applyRule = true; break; case MYSHOP_DISCOUNT_PRICE_CASE_FIRST_BUY: // Fist Order if ($this->handlers->h_myshop_commands->isFirstCommand()) { $applyRule = true; } break; case MYSHOP_DISCOUNT_PRICE_CASE_PRODUCT_NEVER: // Firs time user buy the product if (!$this->handlers->h_myshop_commands->productAlreadyBought(0, $cartProduct['product']->getVar('product_id'))) { $applyRule = true; } break; case MYSHOP_DISCOUNT_PRICE_CASE_QTY_IS: // if quantity of product is... switch ($rule->disc_price_case_qty_cond) { case MYSHOP_DISCOUNT_PRICE_QTY_COND1: // > if ($cartProduct['qty'] > $rule->disc_price_case_qty_value) { $applyRule = true; } break; case MYSHOP_DISCOUNT_PRICE_QTY_COND2: // >= if ($cartProduct['qty'] >= $rule->disc_price_case_qty_value) { $applyRule = true; } break; case MYSHOP_DISCOUNT_PRICE_QTY_COND3: // < if ($cartProduct['qty'] < $rule->disc_price_case_qty_value) { $applyRule = true; } break; case MYSHOP_DISCOUNT_PRICE_QTY_COND4: // <= if ($cartProduct['qty'] <= $rule->disc_price_case_qty_value) { $applyRule = true; } break; case MYSHOP_DISCOUNT_PRICE_QTY_COND5: // == if ($cartProduct['qty'] == $rule->disc_price_case_qty_value) { $applyRule = true; } break; } } } } } } if ($applyRule) { // Apply rule // Calculate product price without fee switch ($rule->disc_price_type) { case MYSHOP_DISCOUNT_PRICE_TYPE1: // Amount related to quantity if ($quantity >= $rule->disc_price_degress_l1qty1 && $quantity <= $rule->disc_price_degress_l1qty2) { $discountedPrice = $rule->disc_price_degress_l1total; } if ($quantity >= $rule->disc_price_degress_l2qty1 && $quantity <= $rule->disc_price_degress_l2qty2) { $discountedPrice = $rule->disc_price_degress_l2total; } if ($quantity >= $rule->disc_price_degress_l3qty1 && $quantity <= $rule->disc_price_degress_l3qty2) { $discountedPrice = $rule->disc_price_degress_l3total; } if ($quantity >= $rule->disc_price_degress_l4qty1 && $quantity <= $rule->disc_price_degress_l4qty2) { $discountedPrice = $rule->disc_price_degress_l4total; } if ($quantity >= $rule->disc_price_degress_l5qty1 && $quantity <= $rule->disc_price_degress_l5qty2) { $discountedPrice = $rule->disc_price_degress_l5total; } $reduction = $rule->disc_description; $discountsCount++; break; case MYSHOP_DISCOUNT_PRICE_TYPE2: // Discount amount or percentage if ($rule->disc_price_amount_on == MYSHOP_DISCOUNT_PRICE_AMOUNT_ON_PRODUCT) { // Discount on product if ($rule->disc_price_amount_type == MYSHOP_DISCOUNT_PRICE_REDUCE_PERCENT) { // Discount percentage $discountedPrice = $this->getDiscountedPrice($discountedPrice, $rule->getVar('disc_price_amount_amount')); } elseif ($rule->disc_price_amount_type == MYSHOP_DISCOUNT_PRICE_REDUCE_MONEY) { // Discount amount $discountedPrice -= floatval($rule->getVar('disc_price_amount_amount')); } // No negative value if ($discountedPrice < 0) { $discountedPrice = 0; } $reduction = $rule->disc_description; $discountsCount++; } elseif ($rule->disc_price_amount_on == MYSHOP_DISCOUNT_PRICE_AMOUNT_ON_CART) { // Rule to apply to cart if (!isset($this->rulesForTheWhole[$rule->disc_id])) { $this->rulesForTheWhole[$rule->disc_id] = $rule; } } break; } // Shipping Fee switch ($rule->disc_shipping_type) { case MYSHOP_DISCOUNT_SHIPPING_TYPE1: // Fee break; case MYSHOP_DISCOUNT_SHIPPING_TYPE2: // Free if user order is more than X euros if ($this->totalAmountBeforeDiscounts > $rule->disc_shipping_free_morethan) { $discountedShipping = 0; } break; case MYSHOP_DISCOUNT_SHIPPING_TYPE3: // Discount on shipping fee of X euros if order is > x if ($this->totalAmountBeforeDiscounts > $rule->disc_shipping_reduce_cartamount) { $discountedShipping -= floatval($rule->disc_shipping_reduce_amount); } // No negative value if ($discountedShipping < 0) { $discountedShipping = 0; } break; case MYSHOP_DISCOUNT_SHIPPING_TYPE4: // Shipping fee degressive if ($quantity >= $rule->disc_shipping_degress_l1qty1 && $quantity <= $rule->disc_shipping_degress_l1qty2) { $discountedShipping = $rule->disc_shipping_degress_l1total; } if ($quantity >= $rule->disc_shipping_degress_l2qty1 && $quantity <= $rule->disc_shipping_degress_l2qty2) { $discountedShipping = $rule->disc_shipping_degress_l2total; } if ($quantity >= $rule->disc_shipping_degress_l3qty1 && $quantity <= $rule->disc_shipping_degress_l3qty2) { $discountedShipping = $rule->disc_shipping_degress_l3total; } if ($quantity >= $rule->disc_shipping_degress_l4qty1 && $quantity <= $rule->disc_shipping_degress_l4qty2) { $discountedShipping = $rule->disc_shipping_degress_l4total; } if ($quantity >= $rule->disc_shipping_degress_l5qty1 && $quantity <= $rule->disc_shipping_degress_l5qty2) { $discountedShipping = $rule->disc_shipping_degress_l5total; } break; } // Discount rule for shipping fee } // Apply discount rule } // Check discounts // Calculate product VAT $vatId = $cartProduct['product']->getVar('product_vat_id'); $vatRate = $vats[$vatId]->getVar('vat_rate'); $vatAmount = myshop_utils::getVAT($discountedPrice * $quantity, $vatRate); // Calculate product all fee ((ht * qte) + vat + shipping) $totalPrice = $discountedPrice * $quantity + $vatAmount + $discountedShipping; // Total $totalHT += $discountedPrice * $quantity; $totalVAT += $vatAmount; $totalShipping += $discountedShipping; // Product related $associatedStore = $associatedCategory = $associatedManufacturers = array(); $manufacturersJoinList = ''; // store if (isset($this->associatedStores[$cartProduct['product']->product_store_id])) { $associatedStore = $this->associatedStores[$cartProduct['product']->product_store_id]->toArray(); } // Catéegory if (isset($this->associatedCategories[$cartProduct['product']->product_cid])) { $associatedCategory = $this->associatedCategories[$cartProduct['product']->product_cid]->toArray(); } // Manufacturers $product_id = $cartProduct['product']->product_id; if (isset($this->associatedManufacturersPerProduct[$product_id])) { $manufacturers = $this->associatedManufacturersPerProduct[$product_id]; $manufacturersList = array(); foreach ($manufacturers as $manufacturer_id) { if (isset($this->associatedManufacturers[$manufacturer_id])) { $associatedManufacturers[] = $this->associatedManufacturers[$manufacturer_id]->toArray(); } $manufacturersList[] = $this->associatedManufacturers[$manufacturer_id]->manu_commercialname . ' ' . $this->associatedManufacturers[$manufacturer_id]->manu_name; } $manufacturersJoinList = implode(MYSHOP_STRING_TO_JOIN_MANUFACTURERS, $manufacturersList); } $productTemplate = array(); $productTemplate = $cartProduct['product']->toArray(); $productTemplate['number'] = $cartProduct['number']; $productTemplate['id'] = $cartProduct['id']; $productTemplate['product_qty'] = $cartProduct['qty']; $productTemplate['unitBasePrice'] = $ht; // Unity price HT (without vat) WITHOUT discount réduction $productTemplate['discountedPrice'] = $discountedPrice; // Unity price HT (without vat) WITH discount $productTemplate['discountedPriceWithQuantity'] = $discountedPrice * $quantity; // Price HT (without vat) WITH discount and quantity // Formated prices $productTemplate['unitBasePriceFormated'] = $myshop_Currency->amountForDisplay($ht); $productTemplate['discountedPriceFormated'] = $myshop_Currency->amountForDisplay($discountedPrice); $productTemplate['discountedPriceWithQuantityFormated'] = $myshop_Currency->amountForDisplay($discountedPrice * $quantity); $productTemplate['vatRate'] = $myshop_Currency->amountInCurrency($vatRate); $productTemplate['vatAmount'] = $vatAmount; $productTemplate['normalShipping'] = $cartProduct['product']->getVar('product_shipping_price'); $productTemplate['discountedShipping'] = $discountedShipping; $productTemplate['totalPrice'] = $totalPrice; $productTemplate['reduction'] = $reduction; $productTemplate['templateProduct'] = $cartProduct['product']->toArray(); $productTemplate['vatAmountFormated'] = $myshop_Currency->amountInCurrency($vatAmount); $productTemplate['normalShippingFormated'] = $myshop_Currency->amountForDisplay($cartProduct['product']->getVar('product_shipping_price')); $productTemplate['discountedShippingFormated'] = $myshop_Currency->amountForDisplay($discountedShipping); $productTemplate['totalPriceFormated'] = $myshop_Currency->amountForDisplay($totalPrice); $productTemplate['templateCategory'] = $associatedCategory; $productTemplate['templateStore'] = $associatedStore; $productTemplate['templateManufacturers'] = $associatedManufacturers; $productTemplate['manufacturersJoinList'] = $manufacturersJoinList; $this->cartForTemplate[] = $productTemplate; } // foreach product in cart // Rules if any if (count($this->rulesForTheWhole) > 0) { // $discountsDescription foreach ($this->rulesForTheWhole as $rule) { switch ($rule->disc_price_type) { case MYSHOP_DISCOUNT_PRICE_TYPE2: // Amount or percentage if ($rule->disc_price_amount_on == MYSHOP_DISCOUNT_PRICE_AMOUNT_ON_CART) { // Rule to apply to cart if ($rule->disc_price_amount_type == MYSHOP_DISCOUNT_PRICE_REDUCE_PERCENT) { // Discount pourcentage $totalHT = $this->getDiscountedPrice($totalHT, $rule->getVar('disc_price_amount_amount')); $totalVAT = $this->getDiscountedPrice($totalVAT, $rule->getVar('disc_price_amount_amount')); } elseif ($rule->disc_price_amount_type == MYSHOP_DISCOUNT_PRICE_REDUCE_MONEY) { // Discount amount $totalHT -= floatval($rule->getVar('disc_price_amount_amount')); $totalVAT -= floatval($rule->getVar('disc_price_amount_amount')); } // No negative value if ($totalHT < 0) { $totalHT = 0; } if ($totalVAT < 0) { $totalVAT = 0; } $discountsDescription[] = $rule->disc_description; $discountsCount++; } // Rule to apply to cart break; } // Switch } // Foreach } // if any global rule // return total $shippingAmount = $totalShipping; $commandAmount = $totalHT; $vatAmount = $totalVAT; $commandAmountTTC = $totalHT + $totalVAT + $totalShipping; $cartForTemplate = $this->cartForTemplate; $emptyCart = false; return true; }
$errstr = ''; $fp = fsockopen($url, 80, $errno, $errstr, 30); if ($fp) { fputs($fp, "{$header}{$req}"); while (!feof($fp)) { $res = fgets($fp, 1024); if (strcmp($res, "VERIFIED") == 0) { $log .= "VERIFIED\t"; $paypalok = true; if (strtoupper($_POST['payment_status']) != 'COMPLETED') { $paypalok = false; } if (strtoupper($_POST['receiver_email']) != strtoupper(myshop_utils::getModuleOption('paypal_email'))) { $paypalok = false; } if (strtoupper($_POST['mc_currency']) != strtoupper(myshop_utils::getModuleOption('paypal_money'))) { $paypalok = false; } if (!$_POST['custom']) { $paypalok = false; } $montant = $_POST['mc_gross']; if ($paypalok) { $ref = intval($_POST['custom']); // Order n° $commande = null; $commande = $h_myshop_commands->get($ref); if (is_object($commande)) { if ($montant == $commande->getVar('cmd_total')) { // Order checked $h_myshop_commands->validateOrder($commande);
if (is_object($item)) { $res = $myshop_shelf->deleteProduct($item, true); if ($res) { myshop_utils::updateCache(); xoops_notification_deletebyitem($xoopsModule->getVar('mid'), 'new_product', $id); myshop_utils::redirect(_AM_MYSHOP_SAVE_OK, $baseurl . '?op=' . $opRedirect, 2); } else { myshop_utils::redirect(_AM_MYSHOP_SAVE_PB, $baseurl . '?op=' . $opRedirect, 5); } } else { myshop_utils::redirect(_AM_MYSHOP_NOT_FOUND, $baseurl . '?op=' . $opRedirect, 5); } } else { myshop_adminMenu(5); myshop_utils::htitle(_AM_MYSHOP_SORRY_NOREMOVE, 4); $tblTmp2 = array(); $tblTmp2 = $h_myshop_commands->getObjects(new Criteria('cmd_id', '(' . implode(',', $tblTmp) . ')', 'IN'), true); echo "<table width='100%' cellspacing='1' cellpadding='3' border='0' class='outer'>"; $class = ''; echo "<tr><th align='center'>" . _AM_MYSHOP_ID . "</th><th align='center'>" . _AM_MYSHOP_DATE . "</th><th align='center'>" . _AM_MYSHOP_CLIENT . "</th><th align='center'>" . _AM_MYSHOP_TOTAL_SHIPP . "</th></tr>"; foreach ($tblTmp2 as $item) { $class = $class == 'even' ? 'odd' : 'even'; $date = formatTimestamp(strtotime($item->getVar('cmd_date')), 's'); echo "<tr class='" . $class . "'>\n"; echo "<td align='right'>" . $item->getVar('cmd_id') . "</td><td align='center'>" . $date . "</td><td align='center'>" . $item->getVar('cmd_lastname') . ' ' . $item->getVar('cmd_firstname') . "</td><td align='center'>" . $item->getVar('cmd_total') . ' ' . myshop_utils::getModuleOption('money_short') . ' / ' . $item->getVar('cmd_shipping') . ' ' . myshop_utils::getModuleOption('money_short') . "</td>\n"; echo "<tr>\n"; } echo '</table>'; } break; }