コード例 #1
0
ファイル: account.shipto.php プロジェクト: noikiy/owaspbwa
    $pathway[] = $vm_mainframe->vmPathwayItem($VM_LANG->_('PHPSHOP_SHOPPER_FORM_SHIPTO_LBL'));
} else {
    // We are in account maintenance
    $pathway[] = $vm_mainframe->vmPathwayItem($VM_LANG->_('PHPSHOP_ACCOUNT_TITLE'), $sess->url(SECUREURL . 'index.php?page=account.index'));
    $pathway[] = $vm_mainframe->vmPathwayItem($VM_LANG->_('PHPSHOP_USER_FORM_SHIPTO_LBL'), $sess->url(SECUREURL . "index.php?page={$next_page}"));
    $pathway[] = $vm_mainframe->vmPathwayItem($VM_LANG->_('PHPSHOP_SHOPPER_FORM_SHIPTO_LBL'));
}
$vm_mainframe->vmAppendPathway($pathway);
// Set the internal VirtueMart pathway
$tpl = vmTemplate::getInstance();
$tpl->set('pathway', $pathway);
$vmPathway = $tpl->fetch('common/pathway.tpl.php');
$tpl->set('vmPathway', $vmPathway);
$missing = vmGet($vars, 'missing');
if (!empty($missing)) {
    echo "<script type=\"text/javascript\">alert('" . $VM_LANG->_('CONTACT_FORM_NC', false) . "'); </script>\n";
}
$db = new ps_DB();
if (!empty($user_info_id)) {
    $q = "SELECT * from #__{vm}_user_info WHERE user_info_id='" . $database->getEscaped($user_info_id) . "' ";
    $q .= " AND user_id='" . $auth['user_id'] . "'";
    $q .= " AND address_type='ST'";
    $db->query($q);
    $db->next_record();
}
if (!$db->num_rows()) {
    $vars['country'] = vmGet($_REQUEST, 'country', $vendor_country);
}
$fields = ps_userfield::getUserFields('shipping');
$tpl->set_vars(array('next_page' => $next_page, 'fields' => $fields, 'missing' => $missing, 'vars' => $vars, 'db' => $db, 'user_info_id' => $user_info_id));
echo $tpl->fetch('pages/' . $page . '.tpl.php');
コード例 #2
0
ファイル: ps_shopper.php プロジェクト: albertobraschi/Hab
 /**
  * Function to update a Shopper Entry
  * (uses who have perms='shopper')
  */
 function update(&$d)
 {
     global $my, $perm, $sess, $vmLogger, $page;
     $auth = $_SESSION['auth'];
     $db = new ps_DB();
     if (@$d["user_id"] != $my->id && @$d["user_id"] != $auth['user_id'] && $auth["perms"] != "admin") {
         $vmLogger->crit("Tricky tricky, but we know about this one.");
         return False;
     }
     require_once CLASSPATH . 'ps_user.php';
     if (!empty($d['username'])) {
         $_POST['username'] = $d['username'];
     } else {
         $_POST['username'] = $my->username;
     }
     $_POST['name'] = $d['first_name'] . " " . $d['last_name'];
     $_POST['id'] = $auth["user_id"];
     $_POST['gid'] = $my->gid;
     $d['error'] = "";
     if (VM_REGISTRATION_TYPE != 'NO_REGISTRATION') {
         ps_user::saveUser($d);
     }
     if (!empty($d['error'])) {
         return false;
     }
     if (!$this->validate_update($d)) {
         return false;
     }
     $user_id = $auth["user_id"];
     /* Update Bill To */
     // Get all fields which where shown to the user
     $userFields = ps_userfield::getUserFields('account', false, '', true);
     $skip_fields = ps_userfield::getSkipFields();
     $fields = array('mdate' => time());
     foreach ($userFields as $userField) {
         if (!in_array($userField->name, $skip_fields)) {
             $fields[$userField->name] = ps_userfield::prepareFieldDataSave($userField->type, $userField->name, vmGet($d, $userField->name, strtoupper($userField->name)));
         }
     }
     $fields['user_email'] = $fields['email'];
     unset($fields['email']);
     $db->buildQuery('UPDATE', '#__{vm}_user_info', $fields, " WHERE user_id=" . $user_id . " AND address_type='BT'");
     // Run the query!
     $db->query();
     // UPDATE #__{vm}_shopper group relationship
     $q = "SELECT shopper_group_id FROM #__{vm}_shopper_vendor_xref ";
     $q .= "WHERE user_id = '" . $user_id . "'";
     $db->query($q);
     if (!$db->num_rows()) {
         //add
         $shopper_db = new ps_DB();
         // get the default shopper group
         $q = "SELECT shopper_group_id from #__{vm}_shopper_group WHERE ";
         $q .= "`default`='1'";
         $shopper_db->query($q);
         if (!$shopper_db->num_rows()) {
             // when there is no "default", take the first in the table
             $q = "SELECT shopper_group_id from #__{vm}_shopper_group";
             $shopper_db->query($q);
         }
         $shopper_db->next_record();
         $my_shopper_group_id = $shopper_db->f("shopper_group_id");
         if (empty($d['customer_number'])) {
             $d['customer_number'] = "";
         }
         $q = "INSERT INTO #__{vm}_shopper_vendor_xref ";
         $q .= "(user_id,vendor_id,shopper_group_id) ";
         $q .= "VALUES ('";
         $q .= $_SESSION['auth']['user_id'] . "','";
         $q .= $_SESSION['ps_vendor_id'] . "','";
         $q .= $my_shopper_group_id . "')";
         $db->query($q);
     }
     $q = "SELECT user_id FROM #__{vm}_auth_user_vendor ";
     $q .= "WHERE user_id = '" . $_SESSION['auth']['user_id'] . "'";
     $db->query($q);
     if (!$db->num_rows()) {
         // Insert vendor relationship
         $q = "INSERT INTO #__{vm}_auth_user_vendor (user_id,vendor_id)";
         $q .= " VALUES ";
         $q .= "('" . $_SESSION['auth']['user_id'] . "','";
         $q .= $_SESSION['ps_vendor_id'] . "') ";
         $db->query($q);
     }
     return True;
 }
コード例 #3
0
ファイル: ps_checkout.php プロジェクト: noikiy/owaspbwa
 /**
  * Calculates the taxable order subtotal for the order.
  * If an item has no weight, it is non taxable.
  * @author Chris Coleman
  * @param array $d
  * @return float Subtotal
  */
 function calc_order_taxable($d)
 {
     $auth = $_SESSION['auth'];
     $cart = $_SESSION['cart'];
     $subtotal = 0.0;
     require_once CLASSPATH . 'ps_product.php';
     $ps_product = new ps_product();
     require_once CLASSPATH . 'ps_shipping_method.php';
     $db = new ps_DB();
     for ($i = 0; $i < $cart["idx"]; $i++) {
         $skip_tax = false;
         // do we skip this product due to zero percent tax rate?
         $tax_rate_id = $ps_product->get_field($cart[$i]["product_id"], 'product_tax_id');
         if ($tax_rate_id != '0') {
             // look up the tax rate
             $q = "SELECT tax_rate FROM #__{vm}_tax_rate WHERE tax_rate_id='{$tax_rate_id}'";
             $db->query($q);
             if ($db->num_rows() > 0) {
                 $tax_rate = $db->f('tax_rate');
                 if ($tax_rate == 0) {
                     $skip_tax = true;
                 }
             }
         }
         $price = $ps_product->get_adjusted_attribute_price($cart[$i]["product_id"], $cart[$i]["description"]);
         $product_price = $GLOBALS['CURRENCY']->convert($price["product_price"], $price['product_currency']);
         $item_weight = ps_shipping_method::get_weight($cart[$i]["product_id"]) * $cart[$i]['quantity'];
         if (($item_weight != 0 or TAX_VIRTUAL == '1') && !$skip_tax) {
             $subtotal += $product_price * $cart[$i]["quantity"];
         }
     }
     return $subtotal;
 }
コード例 #4
0
ファイル: ps_vendor.php プロジェクト: albertobraschi/Hab
 /**
  * Prints a drop-down list of vendor names and their ids.
  *
  * @param int $vendor_id
  */
 function list_vendor($vendor_id = '1')
 {
     $db = new ps_DB();
     $q = "SELECT vendor_id,vendor_name FROM #__{vm}_vendor ORDER BY vendor_name";
     $db->query($q);
     $db->next_record();
     // If only one vendor do not show list
     if ($db->num_rows() == 1) {
         echo '<input type="hidden" name="vendor_id" value="' . $db->f("vendor_id") . '" />';
         echo $db->f("vendor_name");
     } elseif ($db->num_rows() > 1) {
         $db->reset();
         $array = array();
         while ($db->next_record()) {
             $array[$db->f("vendor_id")] = $db->f("vendor_name");
         }
         echo ps_html::selectList('vendor_id', $vendor_id, $array);
     }
 }
コード例 #5
0
 /**
  * Lists all child/sister products of the given product
  *
  * @param int $product_id
  * @return string HTML code with Items, attributes & price
  */
 function list_attribute_list($product_id, $display_use_parent, $child_link, $display_type, $cls_sfuffix, $child_ids, $dw, $aw, $display_header, $product_list_type, $product_list)
 {
     global $CURRENCY_DISPLAY, $mm_action_url;
     require_once CLASSPATH . 'ps_product.php';
     $ps_product = new ps_product();
     require_once CLASSPATH . 'ps_product_type.php';
     $ps_product_type = new ps_product_type();
     $Itemid = vmGet($_REQUEST, 'Itemid', "");
     $category_id = vmGet($_REQUEST, 'category_id', "");
     $curr_product = vmGet($_REQUEST, 'product_id', "");
     $db = new ps_DB();
     $db_sku = new ps_DB();
     $db_item = new ps_DB();
     $tpl = vmTemplate::getInstance();
     $price = $ps_product->get_adjusted_attribute_price($product_id);
     $tpl->set("cls_suffix", $cls_sfuffix);
     $tpl->set("product_id", $product_id);
     $tpl->set("display_header", $display_header);
     $tpl->set("display_product_type", $product_list_type);
     $tpl->set("product_price", $price['product_price']);
     $html = '';
     // Get list of children
     $pp = $ps_product->parent_has_children($product_id);
     if ($pp) {
         $q = "SELECT product_id,product_name,product_parent_id,product_sku,product_in_stock,product_full_image,product_thumb_image FROM #__{vm}_product WHERE product_publish='Y' AND product_parent_id='{$product_id}'  ";
     } else {
         $q = "SELECT product_id,product_name,product_parent_id,product_sku,product_in_stock,product_full_image,product_thumb_image FROM #__{vm}_product WHERE product_publish='Y' AND product_id='{$product_id}'  ";
     }
     if ($child_ids) {
         $ids = explode(",", $child_ids);
         $child_array = array();
         $parent_array = array();
         foreach ($ids as $extra_id) {
             if ($ps_product->parent_has_children($extra_id)) {
                 $parent_array[] = $extra_id;
             } else {
                 $child_array[] = $extra_id;
             }
         }
         $parent_ids = implode(',', $parent_array);
         $child_ids = implode(',', $child_array);
         if ($child_ids) {
             $q .= "UNION ALL SELECT product_id,product_name,product_parent_id,product_sku,product_in_stock,product_full_image,product_thumb_image FROM #__{vm}_product WHERE product_publish='Y' AND  product_id IN ({$child_ids}) ";
         }
         if ($parent_ids) {
             $q .= "UNION ALL SELECT product_id,product_name,product_parent_id,product_sku,product_in_stock,product_full_image,product_thumb_image FROM #__{vm}_product WHERE product_publish='Y' AND  product_parent_id IN ({$parent_ids})";
         }
     }
     $db->query($q);
     if ($pp) {
         $master_id = $product_id;
     } else {
         $master_id = $db->f("product_id");
     }
     $main_master = $master_id;
     $master_child_count = 0;
     if ($db->num_rows() < 1) {
         // Try to Get list of sisters & brothers
         $q = "SELECT product_parent_id FROM #__{vm}_product WHERE product_id='{$product_id}'";
         $db->setQuery($q);
         $db->query();
         $child_id = $product_id;
         $product_id = $db->f("product_parent_id") ? $db->f("product_parent_id") : $product_id;
         $parent_id = $db->f("product_parent_id");
         $q = "SELECT product_id,product_name,product_parent_id,product_sku,product_in_stock FROM #__{vm}_product WHERE product_parent_id='" . $db->f("product_parent_id") . "' AND product_parent_id<>0 AND product_publish='Y'";
         $db->query($q);
     }
     if ($db->num_rows() > 0) {
         $products = array();
         $headings = array();
         $i = 0;
         $attrib_heading = array();
         $ci = 0;
         while ($db->next_record()) {
             $parent_id = $db->f("product_parent_id");
             if ($db->f("product_id") != $curr_product && @$child_id) {
                 continue;
             }
             // Start row for this child
             $q = "SELECT product_id, attribute_name FROM #__{vm}_product_attribute_sku ";
             $q .= "WHERE product_id='" . $db->f("product_parent_id") . "' ORDER BY attribute_list ASC";
             $db_sku->query($q);
             $attrib_value = array();
             while ($db_sku->next_record()) {
                 $q = "SELECT attribute_name,attribute_value ";
                 $q .= "FROM #__{vm}_product_attribute WHERE ";
                 $q .= "product_id='" . $db->f("product_id") . "' AND ";
                 $q .= "attribute_name='" . $db_sku->f("attribute_name") . "'";
                 $db_item->setQuery($q);
                 $db_item->query();
                 while ($db_item->next_record()) {
                     if ($ci == 0) {
                         $attrib_heading[] = $db_item->f("attribute_name");
                         $tpl->set('headings', $attrib_heading);
                     }
                     $attrib_value[] = $db_item->f("attribute_value");
                 }
             }
             if ($main_master == $parent_id) {
                 $master_child_count++;
             }
             $tpl->set('desc_width', $dw);
             $tpl->set('attrib_width', $aw);
             // End show Header Row
             if ($ci % 2) {
                 $bgcolor = "vmRowOne";
             } else {
                 $bgcolor = "vmRowTwo";
             }
             $products[$ci]['bgcolor'] = $bgcolor;
             $products[$ci]['product_id'] = $db->f("product_id");
             $products[$ci]["category_id"] = $category_id;
             $products[$ci]["Itemid"] = $Itemid;
             // If this is a child of a parent set the correct product_id for page return
             if (@$child_id && $pp) {
                 $products[$ci]['parent_id'] = $db->f("product_id");
             } else {
                 $master_id = $parent_id;
                 $products[$ci]['parent_id'] = $parent_id;
             }
             $flypage = $ps_product->get_flypage($products[$ci]['parent_id']);
             $products[$ci]["flypage"] = $flypage;
             // Images
             // If it is item get parent:
             $product_parent_id = $db->f("product_parent_id");
             if ($product_parent_id != 0) {
                 $dbp = new PS_db();
                 $dbp->query("SELECT product_full_image,product_thumb_image,product_name,product_s_desc FROM #__{vm}_product WHERE product_id='{$product_parent_id}'");
                 $dbp->next_record();
             }
             $product_full_image = $parent_id != 0 && !$db->f("product_full_image") ? $dbp->f("product_full_image") : $db->f("product_full_image");
             // Change
             $product_thumb_image = $parent_id != 0 && !$db->f("product_thumb_image") ? $dbp->f("product_thumb_image") : $db->f("product_thumb_image");
             // Change
             $productData = $db->get_row();
             $productArray = get_object_vars($productData);
             $productArray["product_id"] = $db->f("product_id");
             $productArray["product_full_image"] = $product_full_image;
             // to display the full image on flypage
             $productArray["product_thumb_image"] = $product_thumb_image;
             $tpl->set('productArray', $productArray);
             foreach ($productArray as $property => $value) {
                 $tpl->set($property, $value);
             }
             // Assemble the thumbnail image as a link to the full image
             // This function is defined in the theme (theme.php)
             $product_image = $tpl->vmBuildFullImageLink($productArray);
             $products[$ci]['product_image'] = $product_image;
             //Product Description
             $link = "";
             if ($child_link == "Y" && !@$child_id) {
                 $link = "<input type=\"hidden\" id=\"index_id" . $db->f("product_id") . "\" value=\"" . $db->f("product_id") . "\" />\n";
                 // If content plugins are enabled, reload the whole page; otherwise, use ajax
                 if (VM_CONTENT_PLUGINS_ENABLE == '1') {
                     $link .= "<a name=\"" . $db->f("product_name") . $db->f("product_id") . "\"  onclick=\"var id = \$('index_id" . $db->f("product_id") . "').value; if(id != '') { document.location = '" . $mm_action_url . "index.php?option=com_virtuemart&page=shop.product_details&flypage={$flypage}&Itemid={$Itemid}&category_id={$category_id}&product_id=' + id; }\" >";
                 } else {
                     $link .= "<a name=\"" . $db->f("product_name") . $db->f("product_id") . "\"  onclick=\"var id = \$('index_id" . $db->f("product_id") . "').value; if(id != '') { loadNewPage( 'vmMainPage', '" . $mm_action_url . "index2.php?option=com_virtuemart&page=shop.product_details&flypage={$flypage}&Itemid={$Itemid}&category_id={$category_id}&product_id=' + id ); }\" >";
                 }
                 $tpl->set('child_link', true);
             } else {
                 $tpl->set('child_link', false);
             }
             $html1 = $db->f("product_name");
             if ($child_link == "Y" && !@$child_id) {
                 $html1 .= "</a>";
             }
             $products[$ci]['product_title'] = $link . $html1;
             // For each child get attribute values by looping through attribute list
             foreach ($attrib_value as $attribute) {
                 $products[$ci]['attrib_value'][] = $attribute;
             }
             //Show the quantity Box
             $products[$ci]['quantity_box'] = $this->show_quantity_box($master_id, $db->f("product_id"), $product_list, $display_use_parent);
             // Attributes for this item are done.
             // Now get item price
             $price = $ps_product->get_price($db->f("product_id"));
             $price["product_price"] = $GLOBALS['CURRENCY']->convert($price["product_price"], $price["product_currency"]);
             $actual_price = $ps_product->get_adjusted_attribute_price($db->f("product_id"));
             $actual_price["product_price"] = $GLOBALS['CURRENCY']->convert($actual_price["product_price"], $actual_price["product_currency"]);
             if ($_SESSION["auth"]["show_price_including_tax"] == 1) {
                 $tax_rate = 1 + $ps_product->get_product_taxrate($db->f("product_id"));
                 $price['product_price'] *= $tax_rate;
                 $actual_price['product_price'] *= $tax_rate;
             }
             $products[$ci]['price'] = $CURRENCY_DISPLAY->getFullValue($price["product_price"]);
             $products[$ci]['actual_price'] = $CURRENCY_DISPLAY->getFullValue($actual_price["product_price"]);
             // Ouput Product Type
             if ($db->f("product_parent_id") != $product_id) {
                 $product_id = $db->f("product_parent_id");
             }
             $product_type = "";
             if ($product_id != 0 && !$ps_product_type->product_in_product_type($db->f("product_id"))) {
                 $product_type = $ps_product_type->list_product_type($product_id);
             } else {
                 $product_type = $ps_product_type->list_product_type($db->f("product_id"));
             }
             $products[$ci]['product_type'] = $product_type;
             // Child stock
             if ($display_use_parent == 'Y' && !empty($master_id)) {
                 $id = $master_id;
             } else {
                 $id = $db->f("product_id");
             }
             $products[$ci]['product_in_stock'] = ps_product::get_field($id, 'product_in_stock');
             // Output Advanced Attributes
             $products[$ci]['advanced_attribute'] = $this->list_advanced_attribute($db->f("product_id"));
             $products[$ci]['custom_attribute'] = $this->list_custom_attribute($db->f("product_id"));
             $ci++;
         }
         if ($display_type == "radio") {
             $list_type = "radio";
         } else {
             $list_type = "list";
         }
         // Get template and fill
         $tpl->set('products', $products);
         $master_child_count = $master_child_count == 0 ? 1 : $master_child_count;
         $tpl->set('child_count', $master_child_count);
         if ($product_list == "Y") {
             $html = $tpl->fetch('product_details/includes/addtocart_list_single.tpl.php');
         } else {
             $list_type = "multi";
             $html = $tpl->fetch('product_details/includes/addtocart_list_multi.tpl.php');
         }
     } else {
         $html = "<input type=\"hidden\" name=\"product_id\" value=\"{$product_id}\" />\n";
         $html .= "<input type=\"hidden\" name=\"prod_id[]\" value=\"{$product_id}\" />\n";
         // This function lists the "advanced" simple attributes
         $html .= $this->list_advanced_attribute($product_id);
         // This function lists the "custom" simple attributes
         $html .= $this->list_custom_attribute($product_id);
         $html .= '<br />';
         $list_type = "drop";
     }
     return array($html, $list_type);
 }
コード例 #6
0
 /**
  * Lists the payment methods of all available payment modules
  * @static 
  * @param int $payment_method_id
  */
 function list_payment_methods($payment_method_id = 0)
 {
     global $order_total, $sess, $VM_CHECKOUT_MODULES;
     $ps_vendor_id = $_SESSION['ps_vendor_id'];
     $auth = $_SESSION['auth'];
     $ship_to_info_id = vmGet($_REQUEST, 'ship_to_info_id');
     $shipping_rate_id = vmGet($_REQUEST, 'shipping_rate_id');
     require_once CLASSPATH . 'ps_payment_method.php';
     $ps_payment_method = new ps_payment_method();
     require_once CLASSPATH . 'ps_creditcard.php';
     $ps_creditcard = new ps_creditcard();
     $count = 0;
     // Do we have Credit Card Payments?
     $db_cc = new ps_DB();
     $q = "SELECT * from #__{vm}_payment_method,#__{vm}_shopper_group WHERE ";
     $q .= "#__{vm}_payment_method.shopper_group_id=#__{vm}_shopper_group.shopper_group_id ";
     $q .= "AND (#__{vm}_payment_method.shopper_group_id='" . $auth['shopper_group_id'] . "' ";
     $q .= "OR #__{vm}_shopper_group.default='1') ";
     $q .= "AND (enable_processor='' OR enable_processor='Y') ";
     $q .= "AND payment_enabled='Y' ";
     $q .= "AND #__{vm}_payment_method.vendor_id='{$ps_vendor_id}' ";
     $q .= " ORDER BY list_order";
     $db_cc->query($q);
     if ($db_cc->num_rows()) {
         $first_payment_method_id = $db_cc->f("payment_method_id");
         $count += $db_cc->num_rows();
         $cc_payments = true;
     } else {
         $cc_payments = false;
     }
     $db_nocc = new ps_DB();
     $q = "SELECT * from #__{vm}_payment_method,#__{vm}_shopper_group WHERE ";
     $q .= "#__{vm}_payment_method.shopper_group_id=#__{vm}_shopper_group.shopper_group_id ";
     $q .= "AND (#__{vm}_payment_method.shopper_group_id='" . $auth['shopper_group_id'] . "' ";
     $q .= "OR #__{vm}_shopper_group.default='1') ";
     $q .= "AND (enable_processor='B' OR enable_processor='N' OR enable_processor='P') ";
     $q .= "AND payment_enabled='Y' ";
     $q .= "AND #__{vm}_payment_method.vendor_id='{$ps_vendor_id}' ";
     $q .= " ORDER BY list_order";
     $db_nocc->query($q);
     if ($db_nocc->next_record()) {
         $nocc_payments = true;
         $first_payment_method_id = $db_nocc->f("payment_method_id");
         $count += $db_nocc->num_rows();
         $db_nocc->reset();
     } else {
         $nocc_payments = false;
     }
     // Redirect to the last step when there's only one payment method
     if ($VM_CHECKOUT_MODULES['CHECK_OUT_GET_PAYMENT_METHOD']['order'] != $VM_CHECKOUT_MODULES['CHECK_OUT_GET_FINAL_CONFIRMATION']['order']) {
         if ($count <= 1 && $cc_payments == false) {
             vmRedirect($sess->url(SECUREURL . basename($_SERVER['PHP_SELF']) . "?page=checkout.index&payment_method_id={$first_payment_method_id}&ship_to_info_id={$ship_to_info_id}&shipping_rate_id=" . urlencode($shipping_rate_id) . "&checkout_stage=" . $VM_CHECKOUT_MODULES['CHECK_OUT_GET_FINAL_CONFIRMATION']['order'], false, false), "");
         } elseif (isset($order_total) && $order_total <= 0.0) {
             // In case the order total is less than or equal zero, we don't need a payment method
             vmRedirect($sess->url(SECUREURL . basename($_SERVER['PHP_SELF']) . "?page=checkout.index&ship_to_info_id={$ship_to_info_id}&shipping_rate_id=" . urlencode($shipping_rate_id) . "&checkout_stage=" . $VM_CHECKOUT_MODULES['CHECK_OUT_GET_FINAL_CONFIRMATION']['order'], false, false), "");
         }
     }
     $theme = new $GLOBALS['VM_THEMECLASS']();
     $theme->set_vars(array('db_nocc' => $db_nocc, 'db_cc' => $db_cc, 'nocc_payments' => $nocc_payments, 'payment_method_id' => $payment_method_id, 'first_payment_method_id' => $first_payment_method_id, 'count' => $count, 'cc_payments' => $cc_payments, 'ps_creditcard' => $ps_creditcard, 'ps_payment_method' => $ps_payment_method));
     echo $theme->fetch('checkout/list_payment_methods.tpl.php');
 }
コード例 #7
0
ファイル: ps_user.php プロジェクト: noikiy/owaspbwa
 /**
  * Validates the Input Parameters onBeforeUserDelete
  *
  * @param int $id
  * @return boolean
  */
 function validate_delete($id)
 {
     global $my, $vmLogger, $perm, $VM_LANG;
     $auth = $_SESSION['auth'];
     $valid = true;
     if (empty($id)) {
         $vmLogger->err($VM_LANG->_('VM_USER_DELETE_SELECT'));
         return false;
     }
     $db = new ps_DB();
     $q = 'SELECT user_id, perms FROM #__{vm}_user_info WHERE user_id=' . (int) $id;
     $db->query($q);
     // Only check VirtueMart users - the user may be only a CMS user
     if ($db->num_rows() > 0) {
         $perms = $db->f('perms');
         if (!$perm->hasHigherPerms($perms)) {
             $vmLogger->err(sprintf($VM_LANG->_('VM_USER_DELETE_ERR_NOPERMS'), $perms));
             $valid = false;
         }
         if ($id == $my->id) {
             $vmLogger->err($VM_LANG->_('VM_USER_DELETE_ERR_YOURSELF'));
             $valid = false;
         }
     }
     return $valid;
 }
コード例 #8
0
 function list_attribute($product_id, $fils = true)
 {
     global $VM_LANG, $CURRENCY_DISPLAY;
     $ps_product = new ps_product();
     $db = new ps_DB();
     $db_sku = new ps_DB();
     $db_item = new ps_DB();
     // Get list of children
     if ($fils) {
         $q = "SELECT product_id,product_name FROM #__{vm}_product WHERE product_parent_id='{$product_id}' AND product_publish='Y'";
     } else {
         $q = "SELECT product_parent_id FROM #__{vm}_product WHERE product_id='{$product_id}'";
         $db->setQuery($q);
         $db->query();
         $db->next_record();
         $product_parent_id = $db->f("product_parent_id");
         $q = "SELECT product_id,product_name FROM #__{vm}_product WHERE product_parent_id='{$product_parent_id}' AND product_publish='Y'";
     }
     $db->setQuery($q);
     $db->query();
     if ($db->num_rows() > 0) {
         $display = '<select name="product_id" onChange="this.form.add_product_validate.value=0;this.form.submit();">';
         $display .= '<option value="-1">Choisissez un produit item</option>';
         while ($db->next_record()) {
             $display .= '<option value="' . $db->f("product_id") . '"';
             if ($product_id == $db->f("product_id")) {
                 $display .= ' selected="yes"';
             }
             $display .= '>' . $db->f("product_name");
             // For each child get attribute values by looping through attribute list
             $q = "SELECT product_id, attribute_name FROM #__{vm}_product_attribute_sku ";
             $q .= "WHERE product_id='{$product_id}' ORDER BY attribute_list ASC";
             $db_sku->setQuery($q);
             $db_sku->query();
             while ($db_sku->next_record()) {
                 $q = "SELECT attribute_name, attribute_value, product_id ";
                 $q .= "FROM #__{vm}_product_attribute WHERE ";
                 $q .= "product_id='" . $db->f("product_id") . "' AND ";
                 $q .= "attribute_name='" . $db_sku->f("attribute_name") . "'";
                 $db_item->setQuery($q);
                 $db_item->query();
                 while ($db_item->next_record()) {
                     $display .= ' - ' . $db_item->f("attribute_name") . " ";
                     $display .= "(" . $db_item->f("attribute_value") . ")";
                     if (!$db_sku->is_last_record()) {
                         $display .= '; ';
                     }
                 }
             }
             // Attributes for this item are done.
             // Now get item price
             $price = $ps_product->get_price($db->f("product_id"));
             if ($_SESSION["auth"]["show_price_including_tax"] == 1) {
                 $tax_rate = 1 + $ps_product->get_product_taxrate($db->f("product_id"));
                 $price['product_price'] *= $tax_rate;
             }
             $display .= ' - ' . $CURRENCY_DISPLAY->getFullValue($price["product_price"]);
             $display .= '</option>';
         }
         $display .= '</select>';
     } else {
         $display = "<input type=\"hidden\" name=\"product_id\" value=\"{$product_id}\" />\n";
     }
     return $display;
 }
コード例 #9
0
	    <label for="child_' . $db->f("product_id") . '">' . $db->f("product_name") . ' (';
            while ($db_att->next_record()) {
                echo $db_att->f("attribute_name") . ": " . $db_att->f("attribute_value") . "; ";
            }
            echo ')</label><br/>';
        }
        $tabs->endTab();
    }
}
if ($product_id) {
    // SHOW THE WAITING LIST!
    $dbw = new ps_DB();
    $dbw->query('SELECT name, username, user_id, notify_email, notified, notify_date FROM `#__{vm}_waiting_list`
					LEFT JOIN `#__users` ON `user_id` = `id`
					WHERE `product_id`=' . $product_id);
    if ($dbw->num_rows() > 0) {
        $tabs->startTab($VM_LANG->_('PRODUCT_WAITING_LIST_TAB'), 'waiting-list-tab');
        echo '<table class="adminform"><tr><td><h2>' . $VM_LANG->_('PRODUCT_WAITING_LIST_USERLIST') . ':</h2></td></tr>';
        echo '<tr><td><input type="hidden" value="' . $db->f('product_in_stock') . '" name="product_in_stock_old" />';
        echo '<input type="checkbox" value="1" checked="checked" id="notify_users" name="notify_users" /> <label for="notify_users">' . $VM_LANG->_('PRODUCT_WAITING_LIST_NOTIFYUSERS') . '</label><br /><br /></td></tr>';
        echo '<tr><td>';
        while ($dbw->next_record()) {
            if ($dbw->f("notified") == 1) {
                $waiting_notified = ' - <strong style="font-weight:bold">' . $VM_LANG->_('PRODUCT_WAITING_LIST_NOTIFIED') . ' ' . $dbw->f("notify_date") . '</strong>';
            } else {
                $waiting_notified = '';
            }
            if ($dbw->f("user_id") == 0) {
                $waitinglist[] = '<a href="mailto:' . $dbw->f('notify_email') . '">' . $dbw->f('notify_email') . '</a>' . $waiting_notified;
            } else {
                $waitinglist[] = $dbw->f('name') . ' (' . $dbw->f('username') . ' - ' . '<a href="mailto:' . $dbw->f('notify_email') . '">' . $dbw->f('notify_email') . '</a>' . ')' . $waiting_notified;
コード例 #10
0
 function get_price($product_id, $quantity = 0, $check_multiple_prices = false, $result_attributes = '')
 {
     if ($check_multiple_prices) {
         $db = new ps_DB();
         // Get the vendor id for this product.
         $q = "SELECT vendor_id FROM #__{vm}_product WHERE product_id='{$product_id}'";
         $db->setQuery($q);
         $db->query();
         $db->next_record();
         $vendor_id = $db->f("vendor_id");
         $q = "SELECT svx.shopper_group_id, sg.shopper_group_discount FROM #__{vm}_shopper_vendor_xref svx, #__{vm}_orders o, #__{vm}_shopper_group sg";
         $q .= " WHERE svx.user_id=o.user_id AND sg.shopper_group_id=svx.shopper_group_id AND o.order_id=" . $this->order_id;
         $db->query($q);
         $db->next_record();
         $shopper_group_id = $db->f("shopper_group_id");
         $shopper_group_discount = $db->f("shopper_group_discount");
         // Get the default shopper group id for this vendor
         $q = "SELECT shopper_group_id,shopper_group_discount FROM #__{vm}_shopper_group WHERE ";
         $q .= "vendor_id='{$vendor_id}' AND `default`='1'";
         $db->setQuery($q);
         $db->query();
         $db->next_record();
         $default_shopper_group_id = $db->f("shopper_group_id");
         $default_shopper_group_discount = $db->f("shopper_group_discount");
         // Get the product_parent_id for this product/item
         $q = "SELECT product_parent_id FROM #__{vm}_product WHERE product_id='{$product_id}'";
         $db->setQuery($q);
         $db->query();
         $db->next_record();
         $product_parent_id = $db->f("product_parent_id");
         $price_info = array();
         if (!$check_multiple_prices) {
             /* Added for Volume based prices */
             // This is an important decision: we add up all product quantities with the same product_id,
             // regardless to attributes. This gives "real" volume based discount, because our simple attributes
             // depend on one and the same product_id
             $volume_quantity_sql = " AND (('{$quantity}' >= price_quantity_start AND '{$quantity}' <= price_quantity_end)\n                                OR (price_quantity_end='0') OR ('{$quantity}' > price_quantity_end)) ORDER BY price_quantity_end DESC";
             /* End Addition */
         } else {
             $volume_quantity_sql = " ORDER BY price_quantity_start";
         }
         // Getting prices
         //
         // If the shopper group has a price then show it, otherwise
         // show the default price.
         if (!empty($shopper_group_id)) {
             $q = "SELECT product_price, product_price_id, product_currency FROM #__{vm}_product_price WHERE product_id='{$product_id}' AND ";
             $q .= "shopper_group_id='{$shopper_group_id}' {$volume_quantity_sql}";
             $db->setQuery($q);
             $db->query();
             if ($db->next_record()) {
                 $price_info["product_price"] = $db->f("product_price");
                 if ($check_multiple_prices) {
                     $price_info["product_base_price"] = $db->f("product_price");
                     $price_info["product_has_multiple_prices"] = $db->num_rows() > 1;
                 }
                 $price_info["product_price_id"] = $db->f("product_price_id");
                 $price_info["product_currency"] = $db->f("product_currency");
                 $price_info["item"] = true;
                 $GLOBALS['product_info'][$product_id]['price'] = $price_info;
                 return $GLOBALS['product_info'][$product_id]['price'];
             }
         }
         // Get default price
         $q = "SELECT product_price, product_price_id, product_currency FROM #__{vm}_product_price WHERE product_id='{$product_id}' AND ";
         $q .= "shopper_group_id='{$default_shopper_group_id}' {$volume_quantity_sql}";
         $db->setQuery($q);
         $db->query();
         if ($db->next_record()) {
             $price_info["product_price"] = $db->f("product_price") * ((100 - $shopper_group_discount) / 100);
             if ($check_multiple_prices) {
                 $price_info["product_base_price"] = $price_info["product_price"];
                 $price_info["product_has_multiple_prices"] = $db->num_rows() > 1;
             }
             $price_info["product_price_id"] = $db->f("product_price_id");
             $price_info["product_currency"] = $db->f("product_currency");
             $price_info["item"] = true;
             $GLOBALS['product_info'][$product_id]['price'] = $price_info;
             return $GLOBALS['product_info'][$product_id]['price'];
         }
         // Maybe its an item with no price, check again with product_parent_id
         if (!empty($shopper_group_id)) {
             $q = "SELECT product_price, product_price_id, product_currency FROM #__{vm}_product_price WHERE product_id='{$product_parent_id}' AND ";
             $q .= "shopper_group_id='{$shopper_group_id}' {$volume_quantity_sql}";
             $db->setQuery($q);
             $db->query();
             if ($db->next_record()) {
                 $price_info["product_price"] = $db->f("product_price");
                 if ($check_multiple_prices) {
                     $price_info["product_base_price"] = $db->f("product_price");
                     $price_info["product_has_multiple_prices"] = $db->num_rows() > 1;
                 }
                 $price_info["product_price_id"] = $db->f("product_price_id");
                 $price_info["product_currency"] = $db->f("product_currency");
                 $GLOBALS['product_info'][$product_id]['price'] = $price_info;
                 return $GLOBALS['product_info'][$product_id]['price'];
             }
         }
         $q = "SELECT product_price, product_price_id, product_currency FROM #__{vm}_product_price WHERE product_id='{$product_parent_id}' AND ";
         $q .= "shopper_group_id='{$default_shopper_group_id}' {$volume_quantity_sql}";
         $db->setQuery($q);
         $db->query();
         if ($db->next_record()) {
             $price_info["product_price"] = $db->f("product_price") * ((100 - $shopper_group_discount) / 100);
             if ($check_multiple_prices) {
                 $price_info["product_base_price"] = $price_info["product_price"];
                 $price_info["product_has_multiple_prices"] = $db->num_rows() > 1;
             }
             $price_info["product_price_id"] = $db->f("product_price_id");
             $price_info["product_currency"] = $db->f("product_currency");
             $GLOBALS['product_info'][$product_id]['price'] = $price_info;
             return $GLOBALS['product_info'][$product_id]['price'];
         }
         // No price found
         $GLOBALS['product_info'][$product_id]['price'] = false;
         return $GLOBALS['product_info'][$product_id]['price'];
     } else {
         return $GLOBALS['product_info'][$product_id]['price'];
     }
 }
コード例 #11
0
ファイル: ps_cart.php プロジェクト: rafarubert/megafiltros
 /**
  * adds an item to the shopping cart
  * @author pablo
  * @param array $d
  */
 function add(&$d)
 {
     global $sess, $VM_LANG, $cart, $vmLogger, $func;
     $d = $GLOBALS['vmInputFilter']->process($d);
     include_class("product");
     $db = new ps_DB();
     $ci = 0;
     $request_stock = "";
     $total_quantity = 0;
     $total_updated = 0;
     $total_deleted = 0;
     $_SESSION['last_page'] = "shop.product_details";
     if (!empty($d['product_id']) && !isset($d["prod_id"])) {
         if (empty($d['prod_id'])) {
             $d['prod_id'] = array();
         }
         if (is_array($d['product_id'])) {
             $d['prod_id'] = array_merge($d['prod_id'], $d['product_id']);
         } else {
             $d['prod_id'] = array_merge($d['prod_id'], array($d['product_id']));
         }
     }
     //Check to see if a prod_id has been set
     if (!isset($d["prod_id"])) {
         return true;
     }
     $multiple_products = sizeof($d["prod_id"]);
     //Iterate through the prod_id's and perform an add to cart for each one
     for ($ikey = 0; $ikey < $multiple_products; $ikey++) {
         // Create single array from multi array
         $key_fields = array_keys($d);
         foreach ($key_fields as $key) {
             if (is_array($d[$key])) {
                 $e[$key] = @$d[$key][$ikey];
             } else {
                 $e[$key] = $d[$key];
             }
         }
         if ($multiple_products > 1) {
             $func = "cartUpdate";
         }
         $e['product_id'] = $d['product_id'];
         $e['Itemid'] = $d['Itemid'];
         if (is_array($d["prod_id"])) {
             $product_id = $d["prod_id"][$ikey];
         } else {
             $product_id = $e["prod_id"];
         }
         if (is_array($d["quantity"])) {
             $quantity = @$d['quantity'][$ikey];
         } else {
             $quantity = @$e['quantity'];
         }
         // Check for negative quantity
         if ($quantity < 0) {
             vmRequest::setVar('product_id', $product_id);
             $vmLogger->warning($VM_LANG->_('PHPSHOP_CART_ERROR_NO_NEGATIVE', false));
             return False;
         }
         if (!is_numeric($quantity)) {
             vmRequest::setVar('product_id', $product_id);
             $vmLogger->warning($VM_LANG->_('PHPSHOP_CART_ERROR_NO_VALID_QUANTITY', false));
             return False;
         }
         $quantity = intval($quantity);
         // Check to see if checking stock quantity
         if (CHECK_STOCK) {
             $product_in_stock = ps_product::get_field($product_id, 'product_in_stock');
             if (empty($product_in_stock)) {
                 $product_in_stock = 0;
             }
             if ($quantity > $product_in_stock) {
                 //Create an array for out of stock items and continue to next item
                 $request_stock[$ci]['product_id'] = $product_id;
                 $request_stock[$ci]['quantity'] = $quantity;
                 $ci++;
                 continue;
             }
         }
         // Check if product exists and is published
         if (!ps_product::product_exists($product_id)) {
             $vmLogger->tip($VM_LANG->_('VM_CART_PRODUCT_NOTEXIST', false));
             return false;
         }
         // Quick add of item
         $q = "SELECT product_id FROM #__{vm}_product WHERE ";
         $q .= "product_parent_id = " . (int) $product_id;
         $db->query($q);
         if ($db->num_rows()) {
             vmRequest::setVar('product_id', $e["product_id"]);
             $vmLogger->tip($VM_LANG->_('PHPSHOP_CART_SELECT_ITEM', false));
             $_REQUEST['flypage'] = ps_product::get_flypage($e["product_id"]);
             $GLOBALS['page'] = 'shop.product_details';
             return true;
         }
         // Check to see if we already have it
         $updated = 0;
         $result = ps_product_attribute::cartGetAttributes($e);
         if ($result["attribute_given"] == false && !empty($result["advanced_attribute_list"]) || $multiple_products == 1 && ($result["custom_attribute_given"] == false && !empty($result["custom_attribute_list"]))) {
             $_REQUEST['flypage'] = ps_product::get_flypage($product_id);
             $GLOBALS['page'] = 'shop.product_details';
             $vmLogger->tip($VM_LANG->_('PHPSHOP_CART_SELECT_ITEM', false));
             return true;
         }
         //Check for empty custom field and quantity>0 for multiple addto
         //Normally means no info added to a custom field, but once added to a cart the quantity is automatically placed
         //If another item is added and the custom field is left blank for another product already added this will just ignore that item
         if ($multiple_products != 1 && $quantity != 0 && ($result["custom_attribute_given"] == false && !empty($result["custom_attribute_list"]))) {
             $vmLogger->tip($VM_LANG->_('PHPSHOP_CART_SELECT_ITEM', false));
             continue;
         }
         // Check for duplicate and do not add to current quantity
         for ($i = 0; $i < $_SESSION["cart"]["idx"]; $i++) {
             // modified for advanced attributes
             if ($_SESSION['cart'][$i]["product_id"] == $product_id && $_SESSION['cart'][$i]["description"] == $e["description"]) {
                 $updated = 1;
             }
         }
         list($min, $max) = ps_product::product_order_levels($product_id);
         if ($min != 0 && $quantity != 0 && $quantity < $min) {
             eval("\$msg = \"" . $VM_LANG->_('VM_CART_MIN_ORDER', false) . "\";");
             $vmLogger->warning($msg);
             continue;
         }
         if ($max != 0 && $quantity != 0 && $quantity > $max) {
             eval("\$msg = \"" . $VM_LANG->_('VM_CART_MAX_ORDER', false) . "\";");
             $vmLogger->warning($msg);
             continue;
         }
         // If we did not update then add the item
         if (!$updated && $quantity) {
             $k = $_SESSION['cart']["idx"];
             $_SESSION['cart'][$k]["quantity"] = $quantity;
             $_SESSION['cart'][$k]["product_id"] = $product_id;
             $_SESSION['cart'][$k]["parent_id"] = $e["product_id"];
             $_SESSION['cart'][$k]["category_id"] = vmGet($e, 'category_id', 0);
             // added for the advanced attribute modification
             $_SESSION['cart'][$k]["description"] = $e["description"];
             $_SESSION['cart']["idx"]++;
             $total_quantity += $quantity;
         } else {
             list($updated_prod, $deleted_prod) = $this->update($e);
             $total_updated += $updated_prod;
             $total_deleted += $deleted_prod;
         }
         /* next 3 lines added by Erich for coupon code */
         /* if the cart was updated we gotta update any coupon discounts to avoid ppl getting free stuff */
         if (!empty($_SESSION['coupon_discount'])) {
             // Update the Coupon Discount !!
             require_once CLASSPATH . 'ps_coupon.php';
             ps_coupon::process_coupon_code($d);
         }
     }
     // End Iteration through Prod id's
     $cart = $_SESSION['cart'];
     ps_cart::saveCart();
     // Ouput info message with cart update details /*
     if ($total_quantity != 0 || $total_updated != 0 || $total_deleted != 0) {
         if ($total_quantity > 0 && $total_updated == 0) {
             $msg = $VM_LANG->_('VM_CART_PRODUCT_ADDED', false);
         } else {
             $msg = $VM_LANG->_('VM_CART_PRODUCT_UPDATED', false);
         }
         // Comment out the following line to turn off msg i.e. //$vmLogger->tip( $msg );
         $vmLogger->info($msg);
     } else {
         if (@$request_stock) {
             $vmLogger->tip($VM_LANG->_('PHPSHOP_CART_GOTO_WAITING_LIST', false));
         } elseif ($total_quantity == 0) {
             vmRequest::setVar('product_id', $product_id);
             $GLOBALS['last_page'] = 'shop.product_details';
             $vmLogger->warning($VM_LANG->_('PHPSHOP_CART_ERROR_NO_VALID_QUANTITY', false));
             return false;
         } else {
             $vmLogger->tip($VM_LANG->_('PHPSHOP_CART_QUANTITY_EXCEEDED', false));
         }
     }
     // end cart update message */
     // Perform notification of out of stock items
     if (@$request_stock) {
         global $notify;
         $_SESSION['notify'] = array();
         $_SESSION['notify']['idx'] = 0;
         $k = 0;
         $notify = $_SESSION['notify'];
         foreach ($request_stock as $request) {
             $_SESSION['notify'][$k]["prod_id"] = $request['product_id'];
             $_SESSION['notify'][$k]["quantity"] = $request['quantity'];
             $_SESSION['notify']['idx']++;
             $k++;
         }
         if (vmIsXHR()) {
             $GLOBALS['vm_mainframe']->scriptRedirect($sess->url('index.php?page=shop.waiting_list&product_id=' . $product_id, true, false));
         } else {
             vmRedirect($sess->url('index.php?page=shop.waiting_list&product_id=' . $product_id, true, false));
         }
     }
     return True;
 }
コード例 #12
0
 function process_coupon_code($d)
 {
     global $VM_LANG, $vmLogger;
     /* init the database */
     $coupon_db = new ps_DB();
     /* we need some functions from the checkout module */
     require_once CLASSPATH . "ps_checkout.php";
     $checkout = new ps_checkout();
     if (empty($d['total'])) {
         $totals = $checkout->calc_order_totals($d);
         $d['total'] = $totals['order_subtotal'] + $totals['order_tax'] + $totals['order_shipping'] + $totals['order_shipping_tax'] - $totals['payment_discount'];
     }
     $d['coupon_code'] = trim(vmGet($_REQUEST, 'coupon_code'));
     $coupon_id = vmGet($_SESSION, 'coupon_id', null);
     $q = 'SELECT coupon_id, coupon_code, percent_or_total, coupon_value, coupon_type FROM #__{vm}_coupons WHERE ';
     if ($coupon_id) {
         /* the query to select the coupon coupon_code */
         $q .= 'coupon_id = ' . intval($coupon_id);
     } else {
         /* the query to select the coupon coupon_code */
         $q .= 'coupon_code = \'' . $coupon_db->getEscaped($d['coupon_code']) . '\'';
     }
     /* make the query */
     $coupon_db->query($q);
     /* see if we have any fields returned */
     if ($coupon_db->num_rows() > 0) {
         /* we have a record */
         /* see if we are calculating percent or dollar discount */
         if ($coupon_db->f("percent_or_total") == "percent") {
             /* percent */
             //$subtotal = $checkout->calc_order_subtotal( $d );
             /* take the subtotal for calculation of the discount */
             //$_SESSION['coupon_discount'] = round( ($subtotal * $coupon_db->f("coupon_value") / 100), 2);
             $coupon_value = round($d["total"] * $coupon_db->f("coupon_value") / 100, 2);
             if ($d["total"] < $coupon_value) {
                 $coupon_value = (double) $d['total'] + (double) $d['order_tax'];
                 $vmLogger->info(str_replace('{value}', $GLOBALS['CURRENCY_DISPLAY']->getFullValue($coupon_value), $VM_LANG->_('VM_COUPON_GREATER_TOTAL_SETTO')));
             }
             $_SESSION['coupon_discount'] = $coupon_value;
         } else {
             $coupon_value = $coupon_db->f("coupon_value");
             /* Total Amount */
             if ($d["total"] < $coupon_value) {
                 $coupon_value = (double) $d['total'] + (double) $d['order_tax'];
                 $vmLogger->info(str_replace('{value}', $GLOBALS['CURRENCY_DISPLAY']->getFullValue($coupon_value), $VM_LANG->_('VM_COUPON_GREATER_TOTAL_SETTO')));
             }
             $_SESSION['coupon_discount'] = $GLOBALS['CURRENCY']->convert($coupon_value);
         }
         /* mark this order as having used a coupon so people cant go and use coupons over and over */
         $_SESSION['coupon_redeemed'] = true;
         $_SESSION['coupon_id'] = $coupon_db->f("coupon_id");
         $_SESSION['coupon_code'] = $coupon_db->f("coupon_code");
         $_SESSION['coupon_type'] = $coupon_db->f("coupon_type");
     } else {
         /* no record, so coupon_code entered was not valid */
         $GLOBALS['coupon_error'] = $VM_LANG->_('PHPSHOP_COUPON_CODE_INVALID');
         return false;
     }
 }
コード例 #13
0
 }
 $listObj->addCell($is_exported, 'style="text-align: center;"');
 $url = $_SERVER['PHP_SELF'] . "?page={$modulename}.order_print&limitstart={$limitstart}&keyword=" . urlencode($keyword) . "&order_id=" . $db->f("order_id");
 $tmp_cell = "<a href=\"" . $sess->url($url) . "\">" . sprintf("%08d", $db->f("order_id")) . "</a><br />";
 $listObj->addCell($tmp_cell);
 $tmp_cell = $db->f('first_name') . ' ' . $db->f('last_name');
 if ($perm->check('admin') && defined('_VM_IS_BACKEND')) {
     $url = $_SERVER['PHP_SELF'] . "?page=admin.user_form&amp;user_id=" . $db->f("user_id");
     $tmp_cell = '<a href="' . $sess->url($url) . '">' . $tmp_cell . '</a>';
 }
 $listObj->addCell($tmp_cell);
 $pm_db = new ps_DB();
 $q = "SELECT order_id,is_cod ";
 $q .= "FROM #__zasilkovna_orders WHERE order_id= " . $db->f('order_id') . ";";
 $pm_db->query($q);
 if ($pm_db->num_rows() == 0) {
     //if it hasnt been specified manually yet, look to the payment method config
     $q = "SELECT payment_method_id ";
     $q .= "FROM #__{vm}_order_payment WHERE order_id= " . $db->f('order_id') . ";";
     $pm_db->query($q);
     $payment_method_id = $pm_db->f('payment_method_id');
     if ($zas_modul->getConfig('cod' . $payment_method_id)) {
         $is_cod = true;
     } else {
         $is_cod = false;
     }
 } else {
     //if cod type has been specified already, use it
     if ($pm_db->f('is_cod') == 1) {
         $is_cod = true;
     } else {
コード例 #14
0
ファイル: ps_paypal_api.php プロジェクト: noikiy/owaspbwa
 /**
  * Gets the username from joomla if there is one associated to the paypal express payerID
  * @param string $payerID
  * @return string, False on failure
  */
 function ppex_getUsername($payerID)
 {
     global $vmLogger;
     if (empty($payerID)) {
         $vmLogger->debug("Error: No PayerID Given");
         return false;
     }
     $db = new ps_DB();
     $dbb = new ps_DB();
     $q = "SELECT * FROM #__{vm}_user_info WHERE extra_field_3 = '" . $db->getEscaped($payerID) . "' ORDER by mdate DESC";
     $db->query($q);
     if ($db->num_rows() > 0) {
         while ($db->next_record()) {
             $uid = $db->f('user_id');
             //Now lets try and see if the uid has a real username with joomla
             $q2 = "SELECT * FROM #__users WHERE `id` = '" . $db->getEscaped($uid) . "'";
             $dbb->query($q2);
             if ($dbb->num_rows() > 0) {
                 $dbb->next_record();
                 $username = $dbb->f('username');
                 if (!empty($username)) {
                     return $username;
                 }
             }
         }
     }
     return false;
 }
コード例 #15
0
/**
 * return the html code to show a snapshot of a product based on the product id.
 *
 * @param array $params
 * @return string
 */
function return_snapshot(&$params)
{
    global $sess, $VM_LANG, $mosConfig_live_site, $ps_product;
    $db = new ps_DB();
    $html = "";
    $q = "SELECT DISTINCT product_name,product_id,product_parent_id,product_thumb_image,product_s_desc\r\n\t\t\tFROM #__{vm}_product\r\n\t\t\tWHERE product_id IN ({$params['id']})";
    $db->query($q);
    $ordering = explode(",", $params['id']);
    $db->recordx = array();
    foreach ($ordering as $key1 => $value1) {
        foreach ($db->record as $key2 => $value2) {
            $a = "'" . $value2->product_id . "'";
            if ($a == $value1) {
                $db->recordx[] = $value2;
            }
        }
    }
    foreach ($db->record as $key => $value) {
        $db->record[$key] = $db->recordx[$key];
    }
    $product_count = $db->num_rows();
    if ($product_count > 0) {
        $html .= "<table class=\"productsnap\" width=\"{$params['width']}\" border=\"{$params['border']}\" style=\"{$params['style']}\" ";
        $html .= !empty($params['align']) ? "align=\"{$params['align']}\">" : ">";
        $html .= "\n";
        // set up how the rows and columns are displayed
        if ('v' == $params['displayeach']) {
            $row_sep_top = "<tr>\n";
            $row_sep_btm = "</tr>\n";
        } else {
            $row_sep_top = "";
            $row_sep_btm = "";
        }
        if ('h' == $params['displaylist']) {
            $start = "<tr>\n";
            $end = "</tr>\n";
        } else {
            $start = "";
            $end = "";
        }
        if ('h' == $params['displaylist'] && 'v' == $params['displayeach']) {
            $prod_top = "<td valign=\"top\"><table>\n";
            $prod_btm = "</table></td>\n";
        } else {
            if ($params['displaylist'] == $params['displayeach']) {
                $prod_top = "";
                $prod_btm = "";
            } else {
                $prod_top = "<tr>\n";
                $prod_btm = "</tr>\n";
            }
        }
        /*
        eg of display
        list h, each h
        -- prod_sep_top "" -- prod_sep_btm "" -- start = "<tr>" -- end = "</tr>" -- row_sep_top = "<td>" -- row_sep_btm = "</td>"
        <table><tr><td>name</td><td>image</td><td>name</td><td>image</td></tr></table>
        list h, each v
        -- prod_sep_top "<td><table>" -- prod_sep_btm "</table></td>" -- start = "<tr>" -- end = "</tr>" -- row_sep_top = "<tr><td>" -- row_sep_btm = "</td></tr>"
        <table><tr><td><table><tr><td>name</td></tr><tr><td>image</td></tr></table></td><td><table><tr><td>name</td></tr><tr><td>image</td></tr></table></td></tr></table>
        list v, each h
        -- prod_sep_top "<tr>" -- prod_sep_btm "</tr>" -- start = "" -- end = "" -- row_sep_top = "<td>" -- row_sep_btm = "</td>"
        <table><tr><td>name</td><td>image</td></tr><tr><td>name</td><td>image</td></tr></table>
        list v, each v
        -- prod_sep_top "" -- prod_sep_btm "" -- start = "" -- end = "" -- row_sep_top = "<tr><td>" -- row_sep_btm = "</td></tr>"
        <table><tr><td>name</td></tr><tr><td>image</td></tr><tr><td>name</td></tr><tr><td>image</td></tr></table>
        */
        $i = 0;
        $html .= $start;
        while ($db->next_record()) {
            $html .= $prod_top;
            if ('y' == $params['showname']) {
                $html .= $row_sep_top;
                $html .= "<td class=\"product_name\" align=\"center\">" . $db->f("product_name") . "</td>\n";
                $html .= $row_sep_btm;
            }
            if ('y' == $params['showimage']) {
                $html .= $row_sep_top;
                $url = "index.php?page=" . $ps_product->get_flypage($db->f("product_id"));
                if ($db->f("product_parent_id")) {
                    $url = "index.php?page=shop.product_details&amp;flypage=" . $ps_product->get_flypage($db->f("product_parent_id"));
                    $url .= "&amp;product_id=" . $db->f("product_parent_id");
                } else {
                    $url = "index.php?page=shop.product_details&amp;flypage=" . $ps_product->get_flypage($db->f("product_id"));
                    $url .= "&amp;product_id=" . $db->f("product_id");
                }
                $html .= "<td class=\"image\" align=\"center\"><a href=\"" . $sess->url(URL . $url) . "\">";
                $html .= "<img alt=\"" . $db->f("product_name") . "\" hspace=\"7\" src=\"" . IMAGEURL . "/product/" . $db->f("product_thumb_image") . "\" width=\"90\" border=\"0\" />";
                $html .= "</a></td>\n";
                $html .= $row_sep_btm;
            }
            if ('y' == $params['showdesc']) {
                $html .= $row_sep_top;
                $html .= "<td class=\"desc\">" . $db->f("product_s_desc") . "</td>\n";
                $html .= $row_sep_btm;
            }
            if ('y' == $params['showprice']) {
                $html .= $row_sep_top;
                //$html .= "<td class=\"price\">".$PHPSHOP_LANG->_PHPSHOP_CART_PRICE .": ". number_format($price["product_price"],2) . " " . $price["product_currency"]."</td>\n";
                $html .= "<td class=\"price\">" . str_replace("\$", "\\\$", $ps_product->show_price($db->f("product_id"))) . "</td>\n";
                $html .= $row_sep_btm;
            }
            if ('y' == $params['showaddtocart']) {
                if (@$params['quantity'][$i] > 1) {
                    $qty = $params['quantity'][$i];
                } else {
                    $qty = 1;
                }
                $html .= $row_sep_top;
                $html .= "<td class=\"addtocart\">";
                $url = "index.php?page=shop.cart&func=cartAdd&quantity={$qty}&product_id=" . $db->f("product_id");
                $html .= "<a href=\"" . $sess->url(URL . $url) . "\"> " . $VM_LANG->_('PHPSHOP_CART_ADD_TO');
                if (@$params['quantity'][$i] > 1) {
                    $html .= " x{$qty}";
                }
                $html .= "</a><br />\n</td>";
                $html .= $row_sep_btm;
            }
            $html .= $prod_btm;
            $i++;
        }
        $html .= $end;
        $html .= "</table>";
        return $html;
    } else {
        echo 'Product not found';
        return "";
    }
}
コード例 #16
0
 /**
  * Builds a select list of all discounts.
  *
  * @param int $discount_id
  * @param boolean $show_dates Show the discount start and end dates
  * @return string The html for the select list 
  */
 function discount_list($discount_id = 0, $show_dates = true)
 {
     global $VM_LANG, $option;
     $db = new ps_DB();
     $html = "";
     $db->query("SELECT * FROM #__{vm}_product_discount");
     if ($db->num_rows() > 0) {
         $html = "<select name=\"product_discount_id\" class=\"inputbox\" onchange=\"updateDiscountedPrice();\">\n";
         $html .= "<option id=\"*1\" value=\"0\">" . $VM_LANG->_('PHPSHOP_INFO_MSG_VAT_ZERO_LBL') . "</option>\n";
         while ($db->next_record()) {
             if ($db->f("is_percent")) {
                 $id = "*" . (100 - $db->f("amount")) / 100;
             } else {
                 $id = "-" . $db->f("amount");
             }
             $selected = $db->f("discount_id") == $discount_id ? "selected=\"selected\"" : "";
             $html .= "<option id=\"{$id}\" value=\"" . $db->f("discount_id") . "\" {$selected}>" . $db->f("amount");
             $html .= $db->f("is_percent") == "1" ? "%" : $_SESSION['vendor_currency'];
             $start_date = $db->f('start_date') ? strftime('%Y-%m-%d', $db->f('start_date')) : '*';
             $end_date = $db->f('end_date') ? strftime('%Y-%m-%d', $db->f('end_date')) : '*';
             if ($show_dates) {
                 $html .= ' (' . $start_date . ' - ' . $end_date . ')';
             }
             $html .= "</option>\n";
         }
         $html .= "<option value=\"override\">" . $VM_LANG->_('VM_PRODUCT_DISCOUNT_OVERRIDE') . "</option>\n";
         $html .= "</select>\n";
     } else {
         $html = "<input type=\"hidden\" name=\"product_discount_id\" value=\"0\" />\n\r\n      <a href=\"" . $_SERVER['PHP_SELF'] . "?option={$option}&page=product.product_discount_form\" target=\"_blank\">" . $VM_LANG->_('PHPSHOP_PRODUCT_DISCOUNT_ADDDISCOUNT_TIP') . "</a>";
     }
     return $html;
 }
コード例 #17
0
ファイル: ps_manufacturer.php プロジェクト: noikiy/owaspbwa
 /**
  * Prints a drop-down list of manufacturer names and their ids.
  *
  * @param int $manufacturer_id
  */
 function list_manufacturer($manufacturer_id = '0')
 {
     $db = new ps_DB();
     $q = "SELECT manufacturer_id as id,mf_name as name FROM #__{vm}_manufacturer ORDER BY mf_name";
     $db->query($q);
     $db->next_record();
     // If only one vendor do not show list
     if ($db->num_rows() == 1) {
         echo '<input type="hidden" name="manufacturer_id" value="' . $db->f("id") . '" />';
         echo $db->f("name");
     } elseif ($db->num_rows() > 1) {
         $db->reset();
         $array = array();
         while ($db->next_record()) {
             $array[$db->f("id")] = $db->f("name");
         }
         $code = ps_html::selectList('manufacturer_id', $manufacturer_id, $array) . "<br />\n";
         echo $code;
     } else {
         echo '<input type="hidden" name="manufacturer_id" value="1" />Please create at least one Manufacturer!!';
     }
 }
コード例 #18
0
ファイル: ps_html.php プロジェクト: noikiy/owaspbwa
 /**
  * Creates a Javascript based dynamic state list, depending of the selected
  * country of a country drop-down list (specified by $country_list_name)
  *
  * @param string $country_list_name The name of the country select list element
  * @param string $state_list_name The name for this states drop-down list
  * @param string $selected_country_code The 3-digit country code that is pre-selected
  * @param string $selected_state_code The state code of a pre-selected state
  * @return string HTML code containing the dynamic state list
  */
 function dynamic_state_lists($country_list_name, $state_list_name, $selected_country_code = "", $selected_state_code = "")
 {
     global $vendor_country_3_code, $VM_LANG, $vm_mainframe, $mm_action_url, $page;
     $db = new ps_DB();
     if (empty($selected_country_code)) {
         $selected_country_code = $vendor_country_3_code;
     }
     if (empty($selected_state_code)) {
         $selected_state_code = "originalPos";
     } else {
         $selected_state_code = "'" . $selected_state_code . "'";
     }
     $db->query("SELECT c.country_id, c.country_3_code, s.state_name, s.state_2_code\n\t\t\t\t\t\tFROM #__{vm}_country c\n\t\t\t\t\t\tLEFT JOIN #__{vm}_state s \n\t\t\t\t\t\tON c.country_id=s.country_id OR s.country_id IS NULL\n\t\t\t\t\t\tORDER BY c.country_id, s.state_name");
     if ($db->num_rows() > 0) {
         if (!vmIsAdminMode()) {
             $vm_mainframe->addScript($mm_action_url . 'includes/js/mambojavascript.js');
             $vm_mainframe->addScript($mm_action_url . 'includes/js/joomla.javascript.js');
         }
         // Build the State lists for each Country
         $script = "<script language=\"javascript\" type=\"text/javascript\">//<![CDATA[\n";
         $script .= "<!--\n";
         $script .= "var originalOrder = '1';\n";
         $script .= "var originalPos = '{$selected_country_code}';\n";
         $script .= "var states = new Array();\t// array in the format [key,value,text]\n";
         $i = 0;
         $prev_country = '';
         while ($db->next_record()) {
             $country_3_code = $db->f("country_3_code");
             if ($db->f('state_name')) {
                 // Add 'none' to the list of countries that have states:
                 if ($prev_country != $country_3_code && $page == 'tax.tax_form') {
                     $script .= "states[" . $i++ . "] = new Array( '" . $country_3_code . "',' - ','" . $VM_LANG->_('PHPSHOP_NONE') . "' );\n";
                 } elseif ($prev_country != $country_3_code) {
                     $script .= "states[" . $i++ . "] = new Array( '" . $country_3_code . "','',' -= " . $VM_LANG->_('PHPSHOP_SELECT') . " =-' );\n";
                 }
                 $prev_country = $country_3_code;
                 // array in the format [key,value,text]
                 $script .= "states[" . $i++ . "] = new Array( '" . $country_3_code . "','" . $db->f("state_2_code") . "','" . addslashes($db->f("state_name")) . "' );\n";
             } else {
                 $script .= "states[" . $i++ . "] = new Array( '" . $country_3_code . "',' - ','" . $VM_LANG->_('PHPSHOP_NONE') . "' );\n";
             }
         }
         $script .= "\n\t\t\tfunction changeStateList() { \n\t\t\t  var selected_country = null;\n\t\t\t  for (var i=0; i<document.adminForm." . $country_list_name . ".length; i++)\n\t\t\t\t if (document.adminForm." . $country_list_name . "[i].selected)\n\t\t\t\t\tselected_country = document.adminForm." . $country_list_name . "[i].value;\n\t\t\t  changeDynaList('" . $state_list_name . "',states,selected_country, originalPos, originalOrder);\n\t\t\t  \n\t\t\t}\n\t\t\twriteDynaList( 'class=\"inputbox\" name=\"" . $state_list_name . "\" size=\"1\" id=\"state\"', states, originalPos, originalPos, {$selected_state_code} );\n\t\t\t//-->\n\t\t\t//]]></script>";
         return $script;
     }
 }
コード例 #19
0
 /**
  * Checks for childs of the category $category_id
  *
  * @param int $category_id
  * @return boolean True when the category has childs, false when not
  */
 function has_childs($category_id)
 {
     $db = new ps_DB();
     if (empty($GLOBALS['category_info'][$category_id]['has_childs'])) {
         $q = "SELECT category_child_id FROM #__{vm}_category_xref ";
         $q .= "WHERE category_parent_id='{$category_id}' ";
         $db->setQuery($q);
         $db->query();
         if ($db->num_rows() > 0) {
             $GLOBALS['category_info'][$category_id]['has_childs'] = true;
         } else {
             $GLOBALS['category_info'][$category_id]['has_childs'] = false;
         }
     }
     return $GLOBALS['category_info'][$category_id]['has_childs'];
 }
コード例 #20
0
} else {
    $q = "SELECT DISTINCT product_sku FROM #__{vm}_product WHERE ";
    $q .= "product_parent_id='' AND vendor_id='" . $_SESSION['ps_vendor_id'] . "' ";
    $q .= "AND #__{vm}_product.product_publish='Y' ";
    if (CHECK_STOCK && PSHOP_SHOW_OUT_OF_STOCK_PRODUCTS != "1") {
        $q .= " AND product_in_stock > 0 ";
    }
    $q .= "ORDER BY product_name DESC";
}
$db->query($q);
$i = 0;
while ($db->next_record()) {
    $prodlist[$i] = $db->f("product_sku");
    $i++;
}
if ($db->num_rows() == 0) {
    return;
}
?>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
    <?php 
srand((double) microtime() * 10000000);
if (sizeof($prodlist) < $max_items) {
    $max_items = sizeof($prodlist);
}
if (sizeof($prodlist) > 1) {
    $rand_prods = array_rand($prodlist, $max_items);
} else {
    $rand_prods = rand(4545.3545, $max_items);
}
if ($max_items == 1) {
コード例 #21
0
 /**
  * Returns true if the product is in a Product Type
  * @author Zdenek Dvorak
  *
  * @param int $product_id
  * @return boolean
  */
 function product_in_product_type($product_id)
 {
     $db = new ps_DB();
     $q = "SELECT * FROM #__{vm}_product_product_type_xref WHERE product_id='{$product_id}'";
     $db->query($q);
     return $db->num_rows() > 0;
 }
コード例 #22
0
ファイル: ps_product.php プロジェクト: noikiy/owaspbwa
 function featuredProducts($random, $products, $categories)
 {
     global $VM_LANG;
     require_once CLASSPATH . 'ps_product_attribute.php';
     $ps_product_attribute = new ps_product_attribute();
     $db = new ps_DB();
     $tpl = new $GLOBALS['VM_THEMECLASS']();
     $category_id = null;
     if ($categories) {
         $category_id = vmRequest::getInt('category_id');
     }
     if ($category_id) {
         $q = "SELECT DISTINCT product_sku,#__{vm}_product.product_id,product_name,product_s_desc,product_thumb_image, product_full_image, product_in_stock, product_url FROM #__{vm}_product, #__{vm}_product_category_xref, #__{vm}_category WHERE \n";
         $q .= "(#__{vm}_product.product_parent_id='' OR #__{vm}_product.product_parent_id='0') \n";
         $q .= "AND #__{vm}_product.product_id=#__{vm}_product_category_xref.product_id \n";
         $q .= "AND #__{vm}_category.category_id=#__{vm}_product_category_xref.category_id \n";
         $q .= "AND #__{vm}_category.category_id='{$category_id}' \n";
         $q .= "AND #__{vm}_product.product_publish='Y' \n";
         $q .= "AND #__{vm}_product.product_special='Y' \n";
         if (CHECK_STOCK && PSHOP_SHOW_OUT_OF_STOCK_PRODUCTS != "1") {
             $q .= " AND product_in_stock > 0 \n";
         }
         $q .= 'ORDER BY RAND() LIMIT 0, ' . (int) $products;
     } else {
         $q = "SELECT DISTINCT product_sku,product_id,product_name,product_s_desc,product_thumb_image, product_full_image, product_in_stock, product_url FROM #__{vm}_product WHERE ";
         $q .= "(#__{vm}_product.product_parent_id='' OR #__{vm}_product.product_parent_id='0') AND vendor_id='" . $_SESSION['ps_vendor_id'] . "' ";
         $q .= "AND #__{vm}_product.product_publish='Y' ";
         $q .= "AND #__{vm}_product.product_special='Y' ";
         if (CHECK_STOCK && PSHOP_SHOW_OUT_OF_STOCK_PRODUCTS != "1") {
             $q .= " AND product_in_stock > 0 ";
         }
         $q .= 'ORDER BY RAND() LIMIT 0, ' . (int) $products;
     }
     $db->query($q);
     // Output using template
     if ($db->num_rows() > 0) {
         $i = 0;
         $featured_products = array();
         while ($db->next_record()) {
             $flypage = $this->get_flypage($db->f("product_id"));
             $featured_products[$i]['product_sku'] = $db->f("product_sku");
             $featured_products[$i]['product_name'] = $db->f("product_name");
             $price = "";
             if (_SHOW_PRICES == '1') {
                 // Show price, but without "including X% tax"
                 $price = $this->show_price($db->f("product_id"), false);
             }
             $featured_products[$i]['product_price'] = $price;
             $featured_products[$i]['product_s_desc'] = $db->f("product_s_desc");
             $featured_products[$i]['product_url'] = $db->f("product_url");
             $featured_products[$i]['product_thumb'] = $db->f("product_thumb_image");
             $featured_products[$i]['product_full_image'] = $db->f("product_full_image");
             $featured_products[$i]['product_id'] = $db->f("product_id");
             $featured_products[$i]['flypage'] = $flypage;
             $featured_products[$i]['form_addtocart'] = "";
             if (USE_AS_CATALOGUE != '1' && $price != "" && !stristr($price, $VM_LANG->_('PHPSHOP_PRODUCT_CALL')) && !$this->product_has_attributes($db->f('product_id'), true) && $tpl->get_cfg('showAddtocartButtonOnProductList')) {
                 $tpl->set('i', $i);
                 $tpl->set('product_id', $db->f('product_id'));
                 $tpl->set('ps_product_attribute', $ps_product_attribute);
                 $tpl->set('product_in_stock', $db->f('product_in_stock'));
                 $featured_products[$i]['form_addtocart'] = $tpl->fetch('browse/includes/addtocart_form.tpl.php');
                 $featured_products[$i]['has_addtocart'] = true;
             }
             $i++;
         }
         $tpl->set('featured_products', $featured_products);
         return $tpl->fetch('common/featuredProducts.tpl.php');
     }
 }
コード例 #23
0
ファイル: ps_payment_method.php プロジェクト: noikiy/owaspbwa
 /**
  * Returns all payment_methods with given selector in a Radiolist
  *
  * @param string $selector A String like "B" identifying a type of payment methods
  * @param int $payment_method_id An ID to preselect
  * @param boolean $horiz Separate Items with Spaces if true, else with <br />
  * @return string
  */
 function list_payment_radio($selector, $payment_method_id, $horiz)
 {
     global $CURRENCY_DISPLAY, $ps_checkout;
     $ps_vendor_id = $_SESSION["ps_vendor_id"];
     $auth = $_SESSION["auth"];
     $db = new ps_DB();
     if (!isset($ps_checkout)) {
         $ps_checkout = new ps_checkout();
     }
     require_once CLASSPATH . 'ps_shopper_group.php';
     $ps_shopper_group = new ps_shopper_group();
     $q = "SELECT shopper_group_id from #__{vm}_shopper_group WHERE ";
     $q .= "`default`='1' ";
     $db->query($q);
     if (!$db->num_rows()) {
         $q = "SELECT shopper_group_id from #__{vm}_shopper_group";
         $db->query($q);
     }
     $db->next_record();
     $default_shopper_group_id = $db->f("shopper_group_id");
     $q = "SELECT payment_method_id,payment_method_discount, payment_method_discount_is_percent, payment_method_name from #__{vm}_payment_method WHERE ";
     $q .= "(enable_processor='{$selector}') AND ";
     $q .= "payment_enabled='Y' AND ";
     $q .= "vendor_id='{$ps_vendor_id}' AND ";
     if ($auth["shopper_group_id"] == $default_shopper_group_id) {
         $q .= "shopper_group_id='{$default_shopper_group_id}' ";
     } else {
         $q .= "(shopper_group_id='{$default_shopper_group_id}' ";
         $q .= "OR shopper_group_id='" . $auth["shopper_group_id"] . "') ";
     }
     $q .= "ORDER BY list_order";
     $db->query($q);
     $has_result = false;
     // Start radio list
     while ($db->next_record()) {
         $has_result = true;
         echo "<input type=\"radio\" name=\"payment_method_id\" id=\"" . $db->f("payment_method_name") . "\" value=\"" . $db->f("payment_method_id") . "\" ";
         if ($selector == "' OR enable_processor='Y") {
             echo "onchange=\"javascript: changeCreditCardList();\" ";
         }
         if (($db->f("payment_method_id") == $payment_method_id || $db->num_rows() < 2) && !@$GLOBALS['payment_selected']) {
             echo "checked=\"checked\" />\n";
             $GLOBALS['payment_selected'] = true;
         } else {
             echo "/>\n";
         }
         $discount = $ps_checkout->get_payment_discount($db->f("payment_method_id"));
         echo "<label for=\"" . $db->f("payment_method_name") . "\">" . $db->f("payment_method_name");
         if ($discount > 0.0) {
             echo " (- " . $CURRENCY_DISPLAY->getFullValue(abs($discount)) . ") \n";
         } elseif ($discount < 0.0) {
             echo " (+ " . $CURRENCY_DISPLAY->getFullValue(abs($discount)) . ") \n";
         }
         echo "</label>";
         if ($horiz) {
             echo " ";
         } else {
             echo "<br />";
         }
     }
     return $has_result;
 }
コード例 #24
0
ファイル: admin.user_form.php プロジェクト: noikiy/owaspbwa
    $sess->purl($_SERVER['PHP_SELF'] . "?page={$modulename}.user_address_form&amp;user_id={$user_id}");
    ?>
" >
	(<?php 
    echo $VM_LANG->_('PHPSHOP_USER_FORM_ADD_SHIPTO_LBL');
    ?>
)</a> 
	
	<table class="adminlist"> 
		<tr> 
			<td > 
				  <?php 
    $qt = "SELECT * from #__{vm}_user_info WHERE user_id='{$user_id}' AND address_type='ST'";
    $dbt = new ps_DB();
    $dbt->query($qt);
    if (!$dbt->num_rows()) {
        echo "No shipping addresses.";
    } else {
        while ($dbt->next_record()) {
            $url = $sess->url($_SERVER['PHP_SELF'] . "?page={$modulename}.user_address_form&user_id={$user_id}&user_info_id=" . $dbt->f("user_info_id"));
            echo '&raquo; <a href="' . $sess->url($url) . '">';
            echo $dbt->f("address_type_name") . "</a><br/>";
        }
    }
    ?>
 
			</td> 
		</tr> 
	</table>
	</fieldset>
         <?php 
コード例 #25
0
	}
	$q .= "ORDER BY RAND() LIMIT 0, $max_items";
}
else {
	$q  = "SELECT DISTINCT product_sku, product_s_desc, product_desc FROM #__{vm}_product WHERE ";
	$q .= "(#__{vm}_product.product_parent_id='' OR #__{vm}_product.product_parent_id='0') AND vendor_id='".$_SESSION['ps_vendor_id']."' ";
	$q .= "AND #__{vm}_product.product_publish='Y' ";
	$q .= "AND #__{vm}_product.product_special='Y' ";
	if( CHECK_STOCK && PSHOP_SHOW_OUT_OF_STOCK_PRODUCTS != "1") {
		$q .= " AND product_in_stock > 0 ";
	}
	$q .= "ORDER BY RAND() LIMIT 0, $max_items";
}
$db->query($q);

if( $db->num_rows() > 0 ) {
	?>
	<table border="0" cellpadding="0" cellspacing="0">
	<?php
	$i = 0;
	while($db->next_record() ){
		$short_desc = $db->f("product_s_desc");
		$desc = substr($db->f("product_desc"), 0, 50);
		if ($i%2)
		$sectioncolor = "sectiontableentry2";
		else
		$sectioncolor = "sectiontableentry1";

		$width = intval(100 / intval($db->num_rows()));
		if( $display_style == "vertical" ) {
        ?>
コード例 #26
0
// what should be used as the base of the tree?
// ( could be *first* menu item, *site* name, *module*, *menu* name or *text* )
$base = "first";
// in case *text* should be the base node, what text should be displayed?
$basetext = "";
// what category_id is selected?
$category_id = vmRequest::getInt('category_id');
// select menu items from database
$query = "SELECT category_id,category_parent_id,category_name FROM #__{vm}_category, #__{vm}_category_xref ";
$query .= "WHERE #__{vm}_category.category_publish='Y' AND ";
$query .= "#__{vm}_category.category_id=#__{vm}_category_xref.category_child_id ";
$query .= "ORDER BY category_parent_id, list_order, category_name ASC";
$db->query($query);
$db->next_record();
// how many menu items in this menu?
$row = $db->num_rows();
// create a unique tree identifier, in case multiple dtrees are used
// (max one per module)
$tree = "d" . uniqid("tree_");
// start creating the content
// create left aligned table, load the CSS stylesheet and dTree code
$menu_htmlcode .= "<table border=\"0\" cellspacing=\"1\" cellpadding=\"0\" width=\"100%\"><tr><td align=\"left\">\n";
$menu_htmlcode .= "<link rel=\"stylesheet\" href=\"{$js_src}/dtree/dtree.css\" type=\"text/css\" />\n";
$menu_htmlcode .= "<script type=\"text/javascript\" src=\"{$js_src}/dtree/dtree.js\"></script>\n";
$menu_htmlcode .= "<script type=\"text/javascript\">\n";
// create the tree, using the unique name
// pass the live_site parameter on so dTree can find the icons
$menu_htmlcode .= "{$tree} = new dTree('{$tree}',\"{$js_src}\");\n";
// pass on the dTree API parameters
$menu_htmlcode .= "{$tree}.config.useSelection=" . $useSelection . ";\n";
$menu_htmlcode .= "{$tree}.config.useLines=" . $useLines . ";\n";
     //Проверка кода и переводимой за него суммы
     $qv = "\tSELECT `order_id`,\n\t\t\t\t\t\t`order_total`,\n\t\t\t\t\t\t`order_status` \n\t\t\t\tFROM #__{vm}_orders \n\t\t\t\tWHERE \n\t\t\t\t\t\t`order_id`='" . $order_id . "' \n\t\t\t\t\t\tAND `order_total`>='" . $sum . "' \n\t\t\t\t\t\tAND `order_status` in ('" . YM_CHECK_STATUS . "','" . YM_PAYMENT_STATUS . "')";
     $error = 0;
 }
 // Если не определили тип запроса - это ошибка
 if ($error) {
     //Отвечаем серверу Яндекс.Денег, кодом 200 - ИС Контрагента не в состоянии разобрать запрос. Оператор считает ошибку окончательной и не будет осуществлять перевод.
     $rezult = answer($ym_action, $ym_shopID, $order_invoice, 200);
     $error = 1;
 } elseif ($qv) {
     //Запрос в к базе данных о заказе
     $dbbt = new ps_DB();
     $dbbt->query($qv);
     $dbbt->next_record();
     //Если в базе данных найдена строка с соответсвующим номером заказа и статусом "в обработке", то отвечаем ОК
     if ($dbbt->num_rows() == 1) {
         if (strcasecmp(md5("{$ym_action};{$order_amount};{$order_currency};{$order_bank};{$ym_shopID};{$order_invoice};{$order_customer};{$ym_shopPassword}"), $md5) === 0) {
             $time = time();
             $d = array();
             $d['order_id'] = $order_id;
             //Идентификатор записи заказа
             $is_repeat_request = false;
             //Повторный запрос от Яндекс.Денег с тем же invoiceId
             //Ответ на первый запрос paymentAviso от Яндекс.Денег (прием оплаты)
             if ($_REQUEST['action'] == 'paymentAviso' && $dbbt->f('order_status') == YM_CHECK_STATUS) {
                 //Изменяем статус заказа на ОПЛАЧЕН
                 $d['current_order_status'] = YM_CHECK_STATUS;
                 //Текущийщй статус заказа должен быть "Пользоваль подтвердил чек" W
                 $d['order_status'] = YM_PAYMENT_STATUS;
                 //Новый статус заказа - ОПЛАЧЕН O
                 $d['notify_customer'] = 'Y';