/** * Smarty function for returning a product's price, including currency symbol * * @param array $params parameters passed via Smarty * @param object $smarty the current Smarty object * * @return string */ function OnlineStore_productPriceFull($params, $smarty) { require_once SCRIPTBASE . 'ww.plugins/online-store/frontend/smarty-functions.php'; return OnlineStore_productPriceFull2($params, $smarty); }
/** * get a list of products that are related and show them * * @param array $params array of parameters passed to the Smarty function * @param object $smarty the current Smarty object * * @return string the list of products */ function Products_showRelatedProducts($params, $smarty) { global $cdnprefix; $params = array_merge(array('mode' => 'table', 'type' => '', 'thumb_width' => 180, 'thumb_height' => 180, 'button_text' => __('Related Products'), 'template_header' => false, 'template_body' => false), $params); if ($params['mode'] == 'popup') { WW_addScript('products/j/products-related-popup.js'); $button = '<button class="products-related-popup"'; if ($params['template_body']) { $button .= ' data-template-body="' . htmlspecialchars($params['template_body']) . '"'; } if ($params['template_header']) { $button .= ' data-template-header="' . htmlspecialchars($params['template_header']) . '"'; } return $button . '>' . $params['button_text'] . '</button>'; } $product = $smarty->smarty->tpl_vars['product']->value; $productID = $product->id; $type = ''; if ($params['type']) { $tid = dbOne('select id from products_relation_types where name="' . addslashes($params['type']) . '"', 'id'); if ($tid) { $type = ' and relation_id=' . $tid; } } $rs = dbAll('select distinct to_id from products_relations where from_id=' . $productID . $type); if (count($rs)) { $h = array(); $ids = array(); foreach ($rs as $r) { $ids[] = $r['to_id']; } $products = Products::getbyIds($ids); foreach ($products->product_ids as $r) { $p = Product::getInstance($r); if (!$p || !isset($p->id)) { continue; } $h[] = '<a class="product_related" href="' . $p->getRelativeUrl() . '">'; $vals = $p->vals; if (!$vals['images_directory']) { $h[] = htmlspecialchars(__FromJson($p->name)) . '</a>'; continue; } $iid = $p->getDefaultImage(); if (!$iid) { $h[] = htmlspecialchars(__FromJson($p->name)) . '</a>'; continue; } if (!isset($vals['online_store_fields']) || !$vals['online_store_fields']) { $pvat = array("vat" => $_SESSION['onlinestore_vat_percent']); require_once SCRIPTBASE . '/ww.plugins/online-store/frontend/' . 'smarty-functions.php'; $h[] = '<img src="' . $cdnprefix . '/a/w=' . $params['thumb_width'] . '/h=' . $params['thumb_height'] . '/f=getImg/' . $iid . '" />' . OnlineStore_productPriceFull2($pvat, $smarty) . '<p class="product_related_name">' . htmlspecialchars(__fromJSON($p->name)) . '</p></a>'; continue; } $h[] = '<img src="' . $cdnprefix . '/a/w=' . $params['thumb_width'] . '/h=' . $params['thumb_height'] . '/f=getImg/' . $iid . '"/>' . '<br/>' . htmlspecialchars(__fromJSON($p->name)) . '</a>'; } return count($h) ? '<div class="products_related_all">' . '<div class="product_list products_' . htmlspecialchars($params['type']) . '">' . join('', $h) . '</div></div>' : __('none yet'); } return '<p class="no_products_related">' . __('none yet') . '</p>'; }