/** * Returns a list of all reviews for the given product * * @param int $product_id * @param int $limit * @return string */ function product_reviews($product_id, $limit = 0) { global $db, $my, $VM_LANG; $tpl = vmTemplate::getInstance(); $dbc = new ps_DB(); $showall = vmGet($_REQUEST, 'showall', 0); $q = "SELECT comment, time, userid, user_rating FROM #__{vm}_product_reviews \r\n\t\t\t\t\tWHERE product_id='{$product_id}' AND published='Y' ORDER BY `time` DESC "; $count = "SELECT COUNT(*) as num_rows FROM #__{vm}_product_reviews \r\n\t\t\t\t\t\tWHERE product_id='{$product_id}' AND published='Y'"; if ($limit > 0) { $q .= " LIMIT " . intval($limit); } elseif (!$showall) { $q .= " LIMIT 0, 5"; } $dbc->query($count); $num_rows = $dbc->f('num_rows'); $dbc->query($q); $reviews = array(); $i = 0; while ($dbc->next_record()) { $db->query("SELECT username, name FROM #__users WHERE id='" . $dbc->f("userid") . "'"); $db->next_record(); $reviews[$i]['userid'] = $dbc->f("userid"); $reviews[$i]['username'] = $db->f("username"); $reviews[$i]['name'] = $db->f("name"); $reviews[$i]['time'] = $dbc->f("time"); $reviews[$i]['user_rating'] = $dbc->f("user_rating"); $reviews[$i]['comment'] = $dbc->f("comment"); $i++; } $tpl->set('num_rows', $num_rows); $tpl->set('reviews', $reviews); $tpl->set('showall', $showall); return $tpl->fetch('common/reviews.tpl.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 $vendor_currency, $user; require_once CLASSPATH . 'ps_order_status.php'; require_once CLASSPATH . 'ps_userfield.php'; require_once CLASSPATH . 'ps_checkout.php'; require_once CLASSPATH . 'ps_product.php'; $ps_product = new ps_product(); $tpl = vmTemplate::getInstance(); $print = vmGet($_REQUEST, 'pop', 0); $order_id = vmGet($_REQUEST, 'order_id', 0); $tpl->set('print', $print); $tpl->set('order_id', $order_id); $db = new ps_DB(); $q = "SELECT * FROM `#__{vm}_orders` WHERE "; $q .= "user_id=" . $auth["user_id"] . " AND order_id='{$order_id}'"; $db->query($q); if ($db->next_record()) { $mainframe->setPageTitle($VM_LANG->_('PHPSHOP_ACC_ORDER_INFO') . ' : ' . $VM_LANG->_('PHPSHOP_ORDER_LIST_ID') . ' ' . $db->f('order_id')); require_once CLASSPATH . 'ps_product_category.php'; // Set the CMS pathway $pathway = array(); $pathway[] = $vm_mainframe->vmPathwayItem($VM_LANG->_('PHPSHOP_ACCOUNT_TITLE'), $sess->url(SECUREURL . 'index.php?page=account.index')); $pathway[] = $vm_mainframe->vmPathwayItem($VM_LANG->_('PHPSHOP_ACC_ORDER_INFO'));
/** */ function mail_question(&$d) { global $vmLogger, $Itemid, $_SESSION, $VM_LANG, $mosConfig_live_site, $mosConfig_lang, $sess; $db = new ps_DB(); $product_id = (int) $d["product_id"]; $q = 'SELECT * FROM #__{vm}_product WHERE product_id=' . $product_id . ' AND product_publish=\'Y\''; $db->query($q); if (!$db->next_record()) { $vmLogger->err($VM_LANG->_('NOT_AUTH', false)); return false; } if ($db->f("product_sku") != @$d["product_sku"]) { $vmLogger->err($VM_LANG->_('NOT_AUTH', false)); return false; } $Itemid = $sess->getShopItemid(); $flypage = vmGet($_REQUEST, "flypage", null); // product url $product_url = $mosConfig_live_site . "/index.php?option=com_virtuemart&page=shop.product_details&flypage=" . urlencode($flypage) . "&product_id={$product_id}&Itemid={$Itemid}"; $dbv = new ps_DB(); $qt = "SELECT * from #__{vm}_vendor "; $qt .= "WHERE vendor_id = '" . $_SESSION['ps_vendor_id'] . "'"; $dbv->query($qt); $dbv->next_record(); $vendor_email = $dbv->f("contact_email"); $shopper_email = $d["email"]; $shopper_name = $d["name"]; $subject_msg = vmRequest::getVar('text', '', 'post'); $shopper_subject = sprintf($VM_LANG->_('VM_ENQUIRY_SHOPPER_EMAIL_SUBJECT'), $dbv->f("vendor_name")); $shopper_msg = str_replace('{vendor_name}', $dbv->f("vendor_name"), $VM_LANG->_('VM_ENQUIRY_SHOPPER_EMAIL_MESSAGE')); $shopper_msg = str_replace('{product_name}', $db->f("product_name"), $shopper_msg); $shopper_msg = str_replace('{product_sku}', $db->f("product_sku"), $shopper_msg); $shopper_msg = str_replace('{product_url}', $product_url, $shopper_msg); $shopper_msg = vmHtmlEntityDecode($shopper_msg); // $vendor_subject = sprintf($VM_LANG->_('VM_ENQUIRY_VENDOR_EMAIL_SUBJECT'), $dbv->f("vendor_name"), $db->f("product_name")); $vendor_msg = str_replace('{shopper_name}', $shopper_name, $VM_LANG->_('VM_ENQUIRY_VENDOR_EMAIL_MESSAGE')); $vendor_msg = str_replace('{shopper_message}', $subject_msg, $vendor_msg); $vendor_msg = str_replace('{shopper_email}', $shopper_email, $vendor_msg); $vendor_msg = str_replace('{product_name}', $db->f("product_name"), $vendor_msg); $vendor_msg = str_replace('{product_sku}', $db->f("product_sku"), $vendor_msg); $vendor_msg = str_replace('{product_url}', $product_url, $vendor_msg); $vendor_msg = vmHtmlEntityDecode($vendor_msg); //END: set up text mail ///////////////////////////////////// // Send text email // if (ORDER_MAIL_HTML == '0') { // Mail receipt to the shopper vmMail($vendor_email, $dbv->f("vendor_name"), $shopper_email, $shopper_subject, $shopper_msg, ""); // Mail receipt to the vendor vmMail($shopper_email, $shopper_name, $vendor_email, $vendor_subject, $vendor_msg, ""); } elseif (ORDER_MAIL_HTML == '1') { // Mail receipt to the vendor $template = vmTemplate::getInstance(); $template->set_vars(array('vendorname' => $dbv->f("vendor_name"), 'subject' => nl2br($subject_msg), 'contact_name' => $shopper_name, 'contact_email' => $shopper_email, 'product_name' => $db->f("product_name"), 'product_s_description' => $db->f("product_s_desc"), 'product_url' => $product_url, 'product_sku' => $db->f("product_sku"))); if ($db->f("product_thumb_image")) { $imagefile = pathinfo($db->f("product_thumb_image")); $extension = $imagefile['extension'] == "jpg" ? "jpeg" : "jpeg"; $EmbeddedImages[] = array('path' => IMAGEPATH . "product/" . $db->f("product_thumb_image"), 'name' => "product_image", 'filename' => $db->f("product_thumb_image"), 'encoding' => "base64", 'mimetype' => "image/" . $extension); $template->set('product_thumb', '<img src="cid:product_image" alt="product_image" border="0" />'); $body = $template->fetch('order_emails/enquiry_email.tpl.php'); $vendor_mail = vmMail($shopper_email, $shopper_name, $vendor_email, $vendor_subject, $body, $vendor_msg, true, null, null, $EmbeddedImages); } else { $template->set('product_thumb', ''); $body = $template->fetch('order_emails/enquiry_email.tpl.php'); $vendor_mail = vmMail($shopper_email, $shopper_name, $vendor_email, $vendor_subject, $body, $vendor_msg, true, null, null, null); } //Send sender confirmation email $sender_mail = vmMail($vendor_email, $dbv->f("vendor_name"), $shopper_email, $shopper_subject, $shopper_msg, ""); if (!$vendor_mail || !$sender_mail) { $vmLogger->debug('Something went wrong while sending the enquiry email to ' . $vendor_email . ' and ' . $shopper_email); return false; } } return true; }
/** * Create a receipt for the current order and email it to * the customer and the vendor. * @author gday * @author soeren * @param int $order_id * @return boolean True on success, false on failure */ function email_receipt($order_id) { global $sess, $ps_product, $VM_LANG, $CURRENCY_DISPLAY, $vmLogger, $mosConfig_fromname, $mosConfig_lang, $database; $ps_vendor_id = vmGet($_SESSION, 'ps_vendor_id', 1); $auth = $_SESSION["auth"]; require_once CLASSPATH . 'ps_order_status.php'; require_once CLASSPATH . 'ps_userfield.php'; require_once CLASSPATH . 'ps_product.php'; $ps_product = new ps_product(); // Connect to database and gather appropriate order information $db = new ps_DB(); $q = "SELECT * FROM #__{vm}_orders WHERE order_id='{$order_id}'"; $db->query($q); $db->next_record(); $user_id = $db->f("user_id"); $customer_note = $db->f("customer_note"); $order_status = ps_order_status::getOrderStatusName($db->f("order_status")); $dbbt = new ps_DB(); $dbst = new ps_DB(); $qt = "SELECT * FROM #__{vm}_user_info WHERE user_id='" . $user_id . "' AND address_type='BT'"; $dbbt->query($qt); $dbbt->next_record(); $qt = "SELECT * FROM #__{vm}_user_info WHERE user_info_id='" . $db->f("user_info_id") . "'"; $dbst->query($qt); $dbst->next_record(); $dbv = new ps_DB(); $qt = "SELECT * from #__{vm}_vendor "; /* Need to decide on vendor_id <=> order relationship */ $qt .= "WHERE vendor_id = '" . $ps_vendor_id . "'"; $dbv->query($qt); $dbv->next_record(); $dboi = new ps_DB(); $q_oi = "SELECT * FROM #__{vm}_product, #__{vm}_order_item, #__{vm}_orders "; $q_oi .= "WHERE #__{vm}_product.product_id=#__{vm}_order_item.product_id "; $q_oi .= "AND #__{vm}_order_item.order_id='{$order_id}' "; $q_oi .= "AND #__{vm}_orders.order_id=#__{vm}_order_item.order_id"; $dboi->query($q_oi); $db_payment = new ps_DB(); $q = "SELECT op.payment_method_id, pm.payment_method_name FROM #__{vm}_order_payment as op, #__{vm}_payment_method as pm\n WHERE order_id='{$order_id}' AND op.payment_method_id=pm.payment_method_id"; $db_payment->query($q); $db_payment->next_record(); if ($auth["show_price_including_tax"] == 1) { $order_shipping = $db->f("order_shipping"); $order_shipping += $db->f("order_shipping_tax"); $order_shipping_tax = 0; $order_tax = $db->f("order_tax") + $db->f("order_shipping_tax"); } else { $order_shipping = $db->f("order_shipping"); $order_shipping_tax = $db->f("order_shipping_tax"); $order_tax = $db->f("order_tax"); } $order_total = $db->f("order_total"); $order_discount = $db->f("order_discount"); $coupon_discount = $db->f("coupon_discount"); // Email Addresses for shopper and vendor // ************************************** $shopper_email = $dbbt->f("user_email"); $shopper_name = $dbbt->f("first_name") . " " . $dbbt->f("last_name"); $from_email = $dbv->f("contact_email"); $shopper_subject = $dbv->f("vendor_name") . " " . $VM_LANG->_('PHPSHOP_ORDER_PRINT_PO_LBL', false) . " - " . $db->f("order_id"); $vendor_subject = $dbv->f("vendor_name") . " " . $VM_LANG->_('PHPSHOP_ORDER_PRINT_PO_LBL', false) . " - " . $db->f("order_id"); $shopper_order_link = $sess->url(SECUREURL . "index.php?page=account.order_details&order_id={$order_id}", true, false); $vendor_order_link = $sess->url(SECUREURL . "index2.php?page=order.order_print&order_id={$order_id}&pshop_mode=admin", true, false); /** * Prepare the payment information, including Credit Card information when not empty */ $payment_info_details = $db_payment->f("payment_method_name"); if (!empty($_SESSION['ccdata']['order_payment_name']) && !empty($_SESSION['ccdata']['order_payment_number'])) { $payment_info_details .= '<br />' . $VM_LANG->_('PHPSHOP_CHECKOUT_CONF_PAYINFO_NAMECARD', false) . ': ' . $_SESSION['ccdata']['order_payment_name'] . '<br />'; $payment_info_details .= $VM_LANG->_('PHPSHOP_CHECKOUT_CONF_PAYINFO_CCNUM', false) . ': ' . $this->asterisk_pad($_SESSION['ccdata']['order_payment_number'], 4) . '<br />'; $payment_info_details .= $VM_LANG->_('PHPSHOP_CHECKOUT_CONF_PAYINFO_EXDATE', false) . ': ' . $_SESSION['ccdata']['order_payment_expire_month'] . ' / ' . $_SESSION['ccdata']['order_payment_expire_year'] . '<br />'; if (!empty($_SESSION['ccdata']['credit_card_code'])) { $payment_info_details .= 'CVV code: ' . $_SESSION['ccdata']['credit_card_code'] . '<br />'; } } // Convert HTML into Text $payment_info_details_text = str_replace('<br />', "\n", $payment_info_details); // Get the Shipping Details $shipping_arr = explode("|", urldecode(vmGet($_REQUEST, "shipping_rate_id"))); // Headers and Footers // ****************************** // Shopper Header $shopper_header = $VM_LANG->_('PHPSHOP_CHECKOUT_EMAIL_SHOPPER_HEADER1', false) . "\n"; $legal_info_title = ''; $legal_info_html = ''; // Get the legal information about the returns/order cancellation policy if (@VM_ONCHECKOUT_SHOW_LEGALINFO == '1') { $article = intval(@VM_ONCHECKOUT_LEGALINFO_LINK); if ($article > 0) { $db_legal = new ps_DB(); // Get the content article, which contains the Legal Info $db_legal->query('SELECT id, title, introtext FROM #__content WHERE id=' . $article); $db_legal->next_record(); if ($db_legal->f('introtext')) { $legal_info_title = $db_legal->f('title'); $legal_info_text = strip_tags(str_replace('<br />', "\n", $db_legal->f('introtext'))); $legal_info_html = $db_legal->f('introtext'); } } } //Shopper Footer $shopper_footer = "\n\n" . $VM_LANG->_('PHPSHOP_CHECKOUT_EMAIL_SHOPPER_HEADER2', false) . "\n"; if (VM_REGISTRATION_TYPE != 'NO_REGISTRATION') { $shopper_footer .= "\n\n" . $VM_LANG->_('PHPSHOP_CHECKOUT_EMAIL_SHOPPER_HEADER5', false) . "\n"; $shopper_footer .= $shopper_order_link; } $shopper_footer .= "\n\n" . $VM_LANG->_('PHPSHOP_CHECKOUT_EMAIL_SHOPPER_HEADER3', false) . "\n"; $shopper_footer .= "Email: " . $from_email; // New in version 1.0.5 if (@VM_ONCHECKOUT_SHOW_LEGALINFO == '1' && !empty($legal_info_title)) { $shopper_footer .= "\n\n____________________________________________\n"; $shopper_footer .= $legal_info_title . "\n"; $shopper_footer .= $legal_info_text . "\n"; } // Vendor Header $vendor_header = $VM_LANG->_('PHPSHOP_CHECKOUT_EMAIL_SHOPPER_HEADER4', false) . "\n"; // Vendor Footer $vendor_footer = "\n\n" . $VM_LANG->_('PHPSHOP_CHECKOUT_EMAIL_SHOPPER_HEADER5', false) . "\n"; $vendor_footer .= $vendor_order_link; $vendor_email = $from_email; ///////////////////////////////////// // set up text mail // // Main Email Message Purchase Order // ********************************* $shopper_message = "\n" . $VM_LANG->_('PHPSHOP_ORDER_PRINT_PO_LBL', false) . "\n"; $shopper_message .= "------------------------------------------------------------------------\n"; $shopper_message .= $VM_LANG->_('PHPSHOP_ORDER_PRINT_PO_NUMBER', false) . ": " . $db->f("order_id") . "\n"; $shopper_message .= $VM_LANG->_('PHPSHOP_ORDER_PRINT_PO_DATE', false) . ": "; $shopper_message .= strftime($VM_LANG->_('DATE_FORMAT_LC'), $db->f("cdate")) . "\n"; $shopper_message .= $VM_LANG->_('PHPSHOP_ORDER_PRINT_PO_STATUS', false) . ": "; $shopper_message .= $order_status . "\n\n"; // BillTo Fields $registrationfields = ps_userfield::getUserFields('registration', false, '', false, true); foreach ($registrationfields as $field) { if ($field->name == 'email') { $field->name = 'user_email'; } if ($field->name == 'delimiter_sendregistration' || $field->type == 'captcha') { continue; } if ($field->type == 'delimiter') { $shopper_message .= ($VM_LANG->_($field->title) != '' ? $VM_LANG->_($field->title) : $field->title) . "\n"; $shopper_message .= "--------------------\n\n"; } else { $shopper_message .= ($VM_LANG->_($field->title) != '' ? $VM_LANG->_($field->title) : $field->title) . ': '; $shopper_message .= $dbbt->f($field->name) . "\n"; } } // Shipping Fields $shopper_message .= "\n\n"; $shopper_message .= $VM_LANG->_('PHPSHOP_ORDER_PRINT_SHIP_TO_LBL') . "\n"; $shopper_message .= "-------\n\n"; $shippingfields = ps_userfield::getUserFields('shipping', false, '', false, true); foreach ($shippingfields as $field) { if ($field->type == 'delimiter') { $shopper_message .= ($VM_LANG->_($field->title) != '' ? $VM_LANG->_($field->title) : $field->title) . "\n"; $shopper_message .= "--------------------\n\n"; } else { $shopper_message .= ($VM_LANG->_($field->title) != '' ? $VM_LANG->_($field->title) : $field->title) . ': '; $shopper_message .= $dbst->f($field->name) . "\n"; } } $shopper_message .= "\n\n"; $shopper_message .= $VM_LANG->_('PHPSHOP_ORDER_PRINT_ITEMS_LBL', false) . "\n"; $shopper_message .= "-----------"; $sub_total = 0.0; while ($dboi->next_record()) { $shopper_message .= "\n\n"; $shopper_message .= $VM_LANG->_('PHPSHOP_PRODUCT', false) . " = "; if ($dboi->f("product_parent_id")) { $shopper_message .= $dboi->f("order_item_name") . "\n"; $shopper_message .= "SERVICE = "; } $shopper_message .= $dboi->f("product_name") . "; " . $dboi->f("product_attribute") . "\n"; $shopper_message .= $VM_LANG->_('PHPSHOP_ORDER_PRINT_QUANTITY', false) . " = "; $shopper_message .= $dboi->f("product_quantity") . "\n"; $shopper_message .= $VM_LANG->_('PHPSHOP_ORDER_PRINT_SKU', false) . " = "; $shopper_message .= $dboi->f("order_item_sku") . "\n"; $shopper_message .= $VM_LANG->_('PHPSHOP_ORDER_PRINT_PRICE', false) . " = "; if ($auth["show_price_including_tax"] == 1) { $sub_total += $dboi->f("product_quantity") * $dboi->f("product_final_price"); $shopper_message .= $CURRENCY_DISPLAY->getFullValue($dboi->f("product_final_price"), '', $db->f('order_currency')); } else { $sub_total += $dboi->f("product_quantity") * $dboi->f("product_final_price"); $shopper_message .= $CURRENCY_DISPLAY->getFullValue($dboi->f("product_item_price"), '', $db->f('order_currency')); } } $shopper_message .= "\n\n"; $shopper_message .= $VM_LANG->_('PHPSHOP_ORDER_PRINT_SUBTOTAL', false) . " = "; $shopper_message .= $CURRENCY_DISPLAY->getFullValue($sub_total, '', $db->f('order_currency')) . "\n"; if (PAYMENT_DISCOUNT_BEFORE == '1') { if (!empty($order_discount)) { if ($order_discount > 0) { $shopper_message .= $VM_LANG->_('PHPSHOP_PAYMENT_METHOD_LIST_DISCOUNT', false) . " = "; $shopper_message .= "- " . $CURRENCY_DISPLAY->getFullValue(abs($order_discount), '', $db->f('order_currency')) . "\n"; } else { $shopper_message .= $VM_LANG->_('PHPSHOP_FEE', false) . " = "; $shopper_message .= "+ " . $CURRENCY_DISPLAY->getFullValue(abs($order_discount), '', $db->f('order_currency')) . "\n"; } } if (!empty($coupon_discount)) { /* following 2 lines added by Erich for coupon hack */ $shopper_message .= $VM_LANG->_('PHPSHOP_COUPON_DISCOUNT', false) . ": "; $shopper_message .= $CURRENCY_DISPLAY->getFullValue($coupon_discount, '', $db->f('order_currency')) . "\n"; } } if ($auth["show_price_including_tax"] != 1) { $shopper_message .= $VM_LANG->_('PHPSHOP_ORDER_PRINT_TOTAL_TAX', false) . " = "; $shopper_message .= $CURRENCY_DISPLAY->getFullValue($order_tax, '', $db->f('order_currency')) . "\n"; } $shopper_message .= $VM_LANG->_('PHPSHOP_ORDER_PRINT_SHIPPING', false) . " = "; $shopper_message .= $CURRENCY_DISPLAY->getFullValue($order_shipping, '', $db->f('order_currency')) . "\n"; if (!empty($order_shipping_tax)) { $shopper_message .= $VM_LANG->_('PHPSHOP_ORDER_PRINT_SHIPPING_TAX', false) . " = "; $shopper_message .= $CURRENCY_DISPLAY->getFullValue($order_shipping_tax, '', $db->f('order_currency')); } $shopper_message .= "\n\n"; if (PAYMENT_DISCOUNT_BEFORE != '1') { if (!empty($order_discount)) { if ($order_discount > 0) { $shopper_message .= $VM_LANG->_('PHPSHOP_PAYMENT_METHOD_LIST_DISCOUNT', false) . " = "; $shopper_message .= "- " . $CURRENCY_DISPLAY->getFullValue(abs($order_discount), '', $db->f('order_currency')) . "\n"; } else { $shopper_message .= $VM_LANG->_('PHPSHOP_FEE', false) . " = "; $shopper_message .= "+ " . $CURRENCY_DISPLAY->getFullValue(abs($order_discount), '', $db->f('order_currency')) . "\n"; } } if (!empty($coupon_discount)) { /* following 2 lines added by Erich for coupon hack */ $shopper_message .= $VM_LANG->_('PHPSHOP_COUPON_DISCOUNT', false) . ": "; $shopper_message .= $CURRENCY_DISPLAY->getFullValue($coupon_discount, '', $db->f('order_currency')) . "\n"; } } $shopper_message .= $VM_LANG->_('PHPSHOP_ORDER_PRINT_TOTAL', false) . " = "; $shopper_message .= $CURRENCY_DISPLAY->getFullValue($order_total, '', $db->f('order_currency')); if ($auth["show_price_including_tax"] == 1) { $shopper_message .= "\n---------------"; $shopper_message .= "\n"; $shopper_message .= $VM_LANG->_('PHPSHOP_ORDER_PRINT_TOTAL_TAX', false) . " = "; $shopper_message .= $CURRENCY_DISPLAY->getFullValue($order_tax, '', $db->f('order_currency')) . "\n"; } if ($db->f('order_tax_details')) { $shopper_message .= str_replace('<br />', "\n", ps_checkout::show_tax_details($db->f('order_tax_details'), $db->f('order_currency'))); } // Payment Details $shopper_message .= "\n\n------------------------------------------------------------------------\n"; $shopper_message .= $payment_info_details_text; // Shipping Details if (is_object($this->_SHIPPING)) { $shopper_message .= "\n\n------------------------------------------------------------------------\n"; $shopper_message .= $VM_LANG->_('PHPSHOP_ORDER_PRINT_SHIPPING_LBL', false) . ":\n"; $shopper_message .= $shipping_arr[1] . " (" . $shipping_arr[2] . ")"; } // Customer Note $shopper_message .= "\n\n------------------------------------------------------------------------\n"; $shopper_message .= "\n" . $VM_LANG->_('PHPSHOP_ORDER_PRINT_CUSTOMER_NOTE', false) . "\n"; $shopper_message .= "---------------"; $shopper_message .= "\n"; if (!empty($customer_note)) { $shopper_message .= $customer_note . "\n"; } else { $shopper_message .= " ./. \n"; } $shopper_message .= "------------------------------------------------------------------------\n"; // Decode things like € => € $shopper_message = vmHtmlEntityDecode($shopper_message); // End of Purchase Order // ********************* // //END: set up text mail ///////////////////////////////////// // Send text email // if (ORDER_MAIL_HTML == '0') { $msg = $shopper_header . $shopper_message . $shopper_footer; // Mail receipt to the shopper vmMail($from_email, $mosConfig_fromname, $shopper_email, $shopper_subject, $msg, ""); $msg = $vendor_header . $shopper_message . $vendor_footer; // Mail receipt to the vendor vmMail($from_email, $mosConfig_fromname, $vendor_email, $vendor_subject, $msg, ""); } elseif (ORDER_MAIL_HTML == '1') { $dboi->query($q_oi); // Create Template Object $template = vmTemplate::getInstance(); if ($order_discount > 0) { $order_discount_lbl = $VM_LANG->_('PHPSHOP_PAYMENT_METHOD_LIST_DISCOUNT'); $order_discount_plusminus = '-'; } else { $order_discount_lbl = $VM_LANG->_('PHPSHOP_FEE'); $order_discount_plusminus = '+'; } if ($coupon_discount > 0) { $coupon_discount_lbl = $VM_LANG->_('PHPSHOP_PAYMENT_METHOD_LIST_DISCOUNT'); $coupon_discount_plusminus = '-'; } else { $coupon_discount_lbl = $VM_LANG->_('PHPSHOP_FEE'); $coupon_discount_plusminus = '+'; } if (is_object($this->_SHIPPING)) { $shipping_info_details = stripslashes($shipping_arr[1]) . " (" . stripslashes($shipping_arr[2]) . ")"; } else { $shipping_info_details = ' ./. '; } // These are a lot of vars to import for the email confirmation $template->set_vars(array('is_email_to_shopper' => true, 'db' => $db, 'dboi' => $dboi, 'dbbt' => $dbbt, 'dbst' => $dbst, 'ps_product' => $ps_product, 'shippingfields' => $shippingfields, 'registrationfields' => $registrationfields, 'order_id' => $order_id, 'order_discount' => $order_discount, 'order_discount_lbl' => $order_discount_lbl, 'order_discount_plusminus' => $order_discount_plusminus, 'coupon_discount' => $coupon_discount, 'coupon_discount_lbl' => $coupon_discount_lbl, 'coupon_discount_plusminus' => $coupon_discount_plusminus, 'order_date' => $VM_LANG->convert(vmFormatDate($db->f("cdate"), $VM_LANG->_('DATE_FORMAT_LC'))), 'order_status' => $order_status, 'legal_info_title' => $legal_info_title, 'legal_info_html' => $legal_info_html, 'order_link' => $shopper_order_link, 'payment_info_lbl' => $VM_LANG->_('PHPSHOP_ORDER_PRINT_PAYINFO_LBL'), 'payment_info_details' => $payment_info_details, 'shipping_info_lbl' => $VM_LANG->_('PHPSHOP_ORDER_PRINT_SHIPPING_LBL'), 'shipping_info_details' => $shipping_info_details, 'from_email' => $from_email, 'customer_note' => nl2br($customer_note), 'order_header_msg' => $shopper_header, 'order_subtotal' => $CURRENCY_DISPLAY->getFullValue($sub_total, '', $db->f('order_currency')), 'order_shipping' => $CURRENCY_DISPLAY->getFullValue($order_shipping, '', $db->f('order_currency')), 'order_tax' => $CURRENCY_DISPLAY->getFullValue($order_tax, '', $db->f('order_currency')) . ps_checkout::show_tax_details($db->f('order_tax_details'), $db->f('order_currency')), 'order_total' => $CURRENCY_DISPLAY->getFullValue($order_total, '', $db->f('order_currency')))); $shopper_html = $template->fetch('order_emails/confirmation_email.tpl.php'); // Reset the list of order items for use in the vendor email $dboi->reset(); // Override some vars for the vendor email, so we can use the same template $template->set_vars(array('order_header_msg' => $vendor_header, 'order_link' => $vendor_order_link, 'is_email_to_shopper' => false)); $vendor_html = $template->fetch('order_emails/confirmation_email.tpl.php'); /* * Add the text, html and embedded images. * The name of the image should match exactly * (case-sensitive) to the name in the html. */ $shopper_mail_Body = $shopper_html; $shopper_mail_AltBody = $shopper_header . $shopper_message . $shopper_footer; $vendor_mail_Body = $vendor_html; $vendor_mail_AltBody = $vendor_header . $shopper_message . $vendor_footer; $imagefile = pathinfo($dbv->f("vendor_full_image")); $extension = $imagefile['extension'] == "jpg" ? "jpeg" : "jpeg"; $EmbeddedImages[] = array('path' => IMAGEPATH . "vendor/" . $dbv->f("vendor_full_image"), 'name' => "vendor_image", 'filename' => $dbv->f("vendor_full_image"), 'encoding' => "base64", 'mimetype' => "image/" . $extension); $shopper_mail = vmMail($from_email, $mosConfig_fromname, $shopper_email, $shopper_subject, $shopper_mail_Body, $shopper_mail_AltBody, true, null, null, $EmbeddedImages); $vendor_mail = vmMail($from_email, $mosConfig_fromname, $vendor_email, $vendor_subject, $vendor_mail_Body, $vendor_mail_AltBody, true, null, null, $EmbeddedImages, null, $shopper_email); if (!$shopper_mail || !$vendor_mail) { $vmLogger->debug('Something went wrong while sending the order confirmation email to ' . $from_email . ' and ' . $shopper_email); return false; } // // END: set up and send the HTML email //////////////////////////////////////// } return true; }
/** * Returns the availability information as HTML code * @author soeren * @param int $prod_id * @return string */ function get_availability($prod_id) { $html = ''; $availArr = $this->get_availability_data($prod_id); if (!empty($availArr)) { $tpl = vmTemplate::getInstance(); $tpl->set('product_id', $prod_id); $tpl->set('product_available_date', $availArr['product_available_date']); $tpl->set('product_availability', $availArr['product_availability']); $tpl->set('product_in_stock', $availArr['product_in_stock']); $html = $tpl->fetch('common/availability.tpl.php'); } return $html; }
public function display($tpl = null) { $vendorId = vRequest::getInt('vendorid', 1); $vendorModel = VmModel::getModel('vendor'); $vendorIdUser = VmConfig::isSuperVendor(); $vendorModel->setId($vendorId); $vendor = $vendorModel->getVendor(); if(!class_exists('shopFunctionsF'))require(VMPATH_SITE.DS.'helpers'.DS.'shopfunctionsf.php'); if (VmConfig::get ('enable_content_plugin', 0)) { shopFunctionsF::triggerContentPlugin($vendor, 'vendor','vendor_store_desc'); shopFunctionsF::triggerContentPlugin($vendor, 'vendor','vendor_terms_of_service'); } $app = JFactory::getApplication(); $menus = $app->getMenu(); $menu = $menus->getActive(); if(!empty($menu->id)){ ShopFunctionsF::setLastVisitedItemId($menu->id); } else if($itemId = vRequest::getInt('Itemid',false)){ ShopFunctionsF::setLastVisitedItemId($itemId); } $this->assignRef('vendor',$vendor); $document = JFactory::getDocument(); if(!VmConfig::get('shop_is_offline',0)){ vmJsApi::jPrice(); //if($vendorIdUser){ //$user = JFactory::getUser(); if( $vendorIdUser ){ $add_product_link = JURI::root() . 'index.php?option=com_virtuemart&tmpl=component&view=product&task=edit&virtuemart_product_id=0&manage=1' ; $add_product_link = $this->linkIcon($add_product_link, 'COM_VIRTUEMART_PRODUCT_FORM_NEW_PRODUCT', 'edit', false, false); } else { $add_product_link = ""; } $this->assignRef('add_product_link', $add_product_link); //} $categoryModel = VmModel::getModel('category'); $productModel = VmModel::getModel('product'); $ratingModel = VmModel::getModel('ratings'); $productModel->withRating = $this->showRating = $ratingModel->showRating(); $this->products = array(); $categoryId = vRequest::getInt('catid', 0); $categoryChildren = $categoryModel->getChildCategoryList($vendorId, $categoryId); $categoryModel->addImages($categoryChildren,1); $this->assignRef('categories', $categoryChildren); if(!class_exists('CurrencyDisplay'))require(VMPATH_ADMIN.DS.'helpers'.DS.'currencydisplay.php'); $currency = CurrencyDisplay::getInstance( ); $this->assignRef('currency', $currency); $products_per_row = VmConfig::get('homepage_products_per_row',3); $featured_products_rows = VmConfig::get('featured_products_rows',1); $featured_products_count = $products_per_row * $featured_products_rows; if (!empty($featured_products_count) and VmConfig::get('show_featured', 1)) { $this->products['featured'] = $productModel->getProductListing('featured', $featured_products_count); $productModel->addImages($this->products['featured'],1); } $latest_products_rows = VmConfig::get('latest_products_rows'); $latest_products_count = $products_per_row * $latest_products_rows; if (!empty($latest_products_count) and VmConfig::get('show_latest', 1)) { $this->products['latest']= $productModel->getProductListing('latest', $latest_products_count); $productModel->addImages($this->products['latest'],1); } $topTen_products_rows = VmConfig::get('topTen_products_rows'); $topTen_products_count = $products_per_row * $topTen_products_rows; if (!empty($topTen_products_count) and VmConfig::get('show_topTen', 1)) { $this->products['topten']= $productModel->getProductListing('topten', $topTen_products_count); $productModel->addImages($this->products['topten'],1); } $recent_products_rows = VmConfig::get('recent_products_rows'); $recent_products_count = $products_per_row * $recent_products_rows; $recent_products = $productModel->getProductListing('recent'); if (!empty($recent_products_count) and VmConfig::get('show_recent', 1) and !empty($recent_products)) { $this->products['recent']= $productModel->getProductListing('recent', $recent_products_count); $productModel->addImages($this->products['recent'],1); } if ($this->products) { $currency = CurrencyDisplay::getInstance( ); $this->assignRef('currency', $currency); $display_stock = VmConfig::get('display_stock',1); $showCustoms = VmConfig::get('show_pcustoms',1); if($display_stock or $showCustoms){ if(!$showCustoms){ foreach($this->products as $pType => $productSeries){ foreach($productSeries as $i => $productItem){ $productItem->stock = $productModel->getStockIndicator($productItem); } } } else { $customfieldsModel = VmModel::getModel ('Customfields'); if (!class_exists ('vmCustomPlugin')) { require(JPATH_VM_PLUGINS . DS . 'vmcustomplugin.php'); } foreach($this->products as $pType => $productSeries){ foreach($productSeries as $i => $productItem){ if (!empty($productItem->customfields)) { $product = clone($productItem); $customfields = array(); foreach($productItem->customfields as $cu){ $customfields[] = clone ($cu); } $customfieldsSorted = array(); $customfieldsModel -> displayProductCustomfieldFE ($product, $customfields); $product->stock = $productModel->getStockIndicator($product); foreach ($customfields as $k => $custom) { if (!empty($custom->layout_pos) ) { $customfieldsSorted[$custom->layout_pos][] = $custom; unset($customfields[$k]); } } $customfieldsSorted['normal'] = $customfields; $product->customfieldsSorted = $customfieldsSorted; unset($product->customfields); $this->products[$pType][$i] = $product; } else { $productItem->stock = $productModel->getStockIndicator($productItem); $this->products[$pType][$i] = $productItem; } } } } } } $user = JFactory::getUser(); $showBasePrice = ($user->authorise('core.admin','com_virtuemart') or $user->authorise('core.manage','com_virtuemart') or VmConfig::isSuperVendor()); $this->assignRef('showBasePrice', $showBasePrice); $layout = VmConfig::get('vmlayout','default'); $this->setLayout($layout); $productsLayout = VmConfig::get('productsublayout','products'); if(empty($productsLayout)) $productsLayout = 'products'; $this->productsLayout = empty($menu->query['productsublayout'])? $productsLayout:$menu->query['productsublayout']; // Add feed links if ($this->products && (VmConfig::get('feed_featured_published', 0)==1 or VmConfig::get('feed_topten_published', 0)==1 or VmConfig::get('feed_latest_published', 0)==1)) { $link = '&format=feed&limitstart='; $attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0'); $document->addHeadLink(JRoute::_($link . '&type=rss', FALSE), 'alternate', 'rel', $attribs); $attribs = array('type' => 'application/atom+xml', 'title' => 'Atom 1.0'); $document->addHeadLink(JRoute::_($link . '&type=atom', FALSE), 'alternate', 'rel', $attribs); } } else { $this->setLayout('off_line'); } $error = vRequest::getInt('error',0); //Todo this may not work everytime as expected, because the error must be set in the redirect links. if(!empty($error)){ $document->setTitle(vmText::_('COM_VIRTUEMART_PRODUCT_NOT_FOUND').vmText::sprintf('COM_VIRTUEMART_HOME',$vendor->vendor_store_name)); } else { if(empty($vendor->customtitle)){ if ($menu){ $menuTitle = $menu->params->get('page_title'); if(empty($menuTitle)) { $menuTitle = vmText::sprintf('COM_VIRTUEMART_HOME',$vendor->vendor_store_name); } $document->setTitle($menuTitle); } else { $title = vmText::sprintf('COM_VIRTUEMART_HOME',$vendor->vendor_store_name); $document->setTitle($title); } } else { $document->setTitle($vendor->customtitle); } if(!empty($vendor->metadesc)) $document->setMetaData('description',$vendor->metadesc); if(!empty($vendor->metakey)) $document->setMetaData('keywords',$vendor->metakey); if(!empty($vendor->metarobot)) $document->setMetaData('robots',$vendor->metarobot); if(!empty($vendor->metaauthor)) $document->setMetaData('author',$vendor->metaauthor); } if(!class_exists('VmTemplate')) require(VMPATH_SITE.DS.'helpers'.DS.'vmtemplate.php'); vmTemplate::setTemplate(); parent::display($tpl); }
/** * 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; }
foreach ($myInsecureArray as $requestvar => $requestval) { $_REQUEST[$requestvar] = $requestval; } } else { // Strip all tags from all input values $_REQUEST = $vmInputFilter->process($_REQUEST); $_REQUEST = $vmInputFilter->safeSQL($_REQUEST); } // Limit the keyword (=search string) length to 50 $keyword = substr(urldecode(vmGet($_REQUEST, 'keyword')), 0, 50); $vars = vmRequest::get('', VMREQUEST_ALLOWRAW); } // The Page will change with every different parameter / argument, so provide this for identification // "call" will call the function load_that_shop_page when it is not yet cached with exactly THESE parameters // or the caching time range has expired $GLOBALS['cache_id'] = vmTemplate::getCacheId(); if ($option == "com_virtuemart") { // Check if we have to run a Shop Function // and if the user is allowed to execute it $funcParams = $ps_function->getFuncPermissions($func); /********************************************** ** Get Page/Directory Permissions ** Displays error if directory is not registered, ** user has no permission to view it , or file doesn't exist ************************************************/ if (empty($page)) { // default page if (defined('_VM_IS_BACKEND')) { $page = "store.index"; } else { $page = HOMEPAGE;
function vmTheme() { parent::vmTemplate(); vmCommonHTML::loadMooTools(); }
* http://virtuemart.net */ mm_showMyFileName(__FILE__); // Determine settings based on CMS version if (vmIsJoomla('1.5')) { // Post action $action = 'index.php?option=com_user&task=login'; // Return URL $uri = JFactory::getURI(); $url = $uri->toString(); $return_url = base64_encode($url); // Set the validation value $validate = JUtility::getToken(); } else { // Post action $action = 'index.php?option=login'; // Return URL $return_url = vmGet($_SERVER, 'REQUEST_URI', null); // Convert & to & for xhtml compliance $return_url = str_replace('&', '&', $return_url); $return_url = str_replace('option', '&option', $return_url); // Set the validation value if (function_exists('josspoofvalue')) { $validate = josSpoofValue(1); } else { $validate = vmSpoofValue(1); } } $theme = vmTemplate::getInstance(); $theme->set_vars(array('action' => $action, 'return_url' => $return_url, 'validate' => $validate, 'VM_LANG' => $VM_LANG, 'mosConfig_lang' => $mosConfig_lang)); echo $theme->fetch('common/login_form.tpl.php');
/** * Returns html code for show parameters * @author Zdenek Dvorak * * @param int $product_id * @return string */ function list_product_type($product_id) { global $VM_LANG; $tpl = vmTemplate::getInstance(); if (!$this->product_in_product_type($product_id)) { return ""; } // $dbag = product_types; $dbag = new ps_DB(); // $dba = Attributes of product_type param, holds product_id and values assign to each param; $dba = new ps_DB(); // $dbp = Parameters of product_type, holds definitions of each parameter, but not value ; $dbp = new ps_DB(); $html = ""; $q = "SELECT * FROM #__{vm}_product_product_type_xref "; $q .= "LEFT JOIN #__{vm}_product_type USING (product_type_id) "; $q .= "WHERE product_id='{$product_id}' AND product_type_publish='Y' "; $q .= "ORDER BY product_type_list_order"; $dbag->query($q); $q = "SELECT * FROM #__{vm}_product_type_parameter "; $q .= "WHERE product_type_id="; $pt = 0; //product_type counter; while ($dbag->next_record()) { // Show all Product Type if ($dbag->f("product_type_flypage")) { $flypage_file = VM_THEMEPATH . "templates/" . $dbag->f("product_type_flypage") . ".php"; if (file_exists($flypage_file)) { $html .= (include $flypage_file); continue; } } $product_types[$pt]["product_type_name"] = $dbag->f("product_type_name"); // SELECT parameter value of product $q2 = "SELECT * FROM #__{vm}_product_type_" . $dbag->f("product_type_id"); $q2 .= " WHERE product_id='{$product_id}'"; $dbp->query($q2); // SELECT parameter of Product Type $dba->query($q . $dbag->f("product_type_id") . " ORDER BY parameter_list_order"); $i = 0; // parameter counter; while ($dba->next_record()) { $product_type_param[$i]["parameter_label"] = $dba->f("parameter_label"); $parameter_description = $dba->f("parameter_description"); $product_type_param[$i]["parameter_description"] = $parameter_description; if (!empty($parameter_description)) { $product_type_param[$i]["tooltip"] = vmToolTip($parameter_description, $VM_LANG->_('PHPSHOP_PRODUCT_TYPE_PARAMETER_FORM_DESCRIPTION')); } $product_type_param[$i]["parameter_value"] = $dbp->f($dba->f("parameter_name")); $product_type_param[$i]["parameter_unit"] = $dba->f("parameter_unit"); $i++; } $product_types[$pt]["product_type_count_params"] = $i; $product_types[$pt]["parameters"] = $product_type_param; $pt++; } $tpl->set('product_types', $product_types); $html .= $tpl->fetch('common/product_type.tpl.php'); return $html; }
/** * Appends items to the CMS pathway * * @param string $pathway_items Array of pathway objects ($name, $link) * @access public */ function vmAppendPathway($pathway) { global $mainframe, $sess; // Only add the extra pathway if the menu item is using the default VM Itemid $Itemid = $_REQUEST['Itemid']; if ($Itemid && $Itemid != $sess->getShopItemid()) { return; } // Remove the link on the last pathway item $pathway[count($pathway) - 1]->link = ''; if (vmIsJoomla('1.5')) { $cmsPathway =& $mainframe->getPathway(); foreach ($pathway as $item) { $item->link = str_replace('&', '&', $item->link); // make sure that ' (apostrophe) is converted to ' $item->name = html_entity_decode($item->name, ENT_QUOTES); $cmsPathway->addItem($item->name, $item->link); } } else { $tpl = vmTemplate::getInstance(); $tpl->set('pathway', $pathway); $vmPathway = $tpl->fetch('common/pathway.tpl.php'); $mainframe->appendPathWay($vmPathway); } }
/** * Appends items to the CMS pathway * * @param string $pathway_items Array of pathway objects ($name, $link) * @access public */ function vmAppendPathway($pathway) { global $mainframe; // Remove the link on the last pathway item $pathway[count($pathway) - 1]->link = ''; if (vmIsJoomla('1.5')) { $cmsPathway =& $mainframe->getPathway(); foreach ($pathway as $item) { $item->link = str_replace('&', '&', $item->link); // make sure that ' (apostrophe) is converted to ' $item->name = html_entity_decode($item->name, ENT_QUOTES); $cmsPathway->addItem($item->name, $item->link); } } else { $tpl = vmTemplate::getInstance(); $tpl->set('pathway', $pathway); $vmPathway = $tpl->fetch('common/pathway.tpl.php'); $mainframe->appendPathWay($vmPathway); } }
/** * Appends items to the CMS pathway * * @param string $pathway_items Array of pathway objects ($name, $link) * @access public */ function vmAppendPathway($pathway) { global $mainframe; // Remove the link on the last pathway item $pathway[count($pathway) - 1]->link = ''; if (vmIsJoomla('1.5')) { $cmsPathway =& $mainframe->getPathway(); foreach ($pathway as $item) { $cmsPathway->addItem($item->name, str_replace('&', '&', $item->link)); } } else { $tpl = vmTemplate::getInstance(); $tpl->set('pathway', $pathway); $vmPathway = $tpl->fetch('common/pathway.tpl.php'); $mainframe->appendPathWay($vmPathway); } }