OSCommerce에서 "오래된"상점 문제로 작업합니다. 이전 소유자가 조정할 수있는 다중 저장소 구성입니다. 나는 가격 계획 또는 수량 가격 브레이크 기능이있는 유사한 제품이 2 개 있습니다.OSCommerce 가격 일정이 일관성없는 동작
문제는 2 개의 제품 중 1 개가 장바구니에 추가되거나 제품 페이지를 표시 할 때 일관되게 반응하지 않는 것입니다.
1st product :> 5,> 10,> 20 및> 30의 가격 일정이 있으며 가격이 높거나 낮습니다.
2nd product : 일정이 같지만> 30,> 20,> 10 및> 5와 같이 가격이 다소 낮습니다.
별난 것은 가격 순서 표에 sort_order 옵션이 없기 때문에 수량 순서가 임의로 표시되지만 항상 높음에서 낮음 또는 낮음에서 높음입니다.
첫 번째 제품은 장바구니에 올바른 가격을 보여 주며 두 번째 제품은 항상 최고 가격을 보여 주므로 장바구니는 가격 일정 데이터에 따라 가격을 조정해야합니다.
은 운이없이 지금까지 완료 : 것을 발견 한 후 백엔드에서 가격이 일정 구성
- 제품 이름, 제품 이미지 및 product_id와 같은 유일한 차이점은 제품에 product_id를 제공하는 것입니다. 또한 관련된 모든 데이터베이스 항목을 변경했습니다.
- 올바르게 작동하는 제품의 복사본을 만들고 가격 일정을 추가하십시오. 에 주저하지 말고, 내가 클래스를 해독하고 더 많은 정보가 필요하면, 이상한 것들을 찾을 정도로 경험이 아니에요
<?php /* $Id: price_schedule.php,v 1.0 2004/08/23 22:50:52 rmh Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2003 osCommerce Released under the GNU General Public License */ /* price_schedule.php - module to support customer classes with quantity pricing Originally Created 2003, Beezle Software based on some code mods by WasaLab Oy (Thanks!) Modified by Ryan Hobbs (hobbzilla) */ class PriceFormatter { var $hiPrice; var $lowPrice; var $quantity; var $hasQuantityPrice; var $hasSpecialPrice; var $qtyPriceBreaks; function PriceFormatter($prices=NULL) { $this->productsID = -1; $this->hasQuantityPrice=false; $this->hasSpecialPrice=false; $this->hiPrice=-1; $this->lowPrice=-1; $this->thePrice = -1; $this->specialPrice = -1; $this->qtyBlocks = 1; $this->qtyPriceBreaks = 0; if($prices) { $this->parse($prices); } } function encode() { $str = $this->productsID . ":" . (($this->hasQuantityPrice == true) ? "1" : "0") . ":" . (($this->hasSpecialPrice == true) ? "1" : "0") . ":" . $this->quantity[1] . ":" . $this->quantity[2] . ":" . $this->quantity[3] . ":" . $this->quantity[4] . ":" . $this->price[1] . ":" . $this->price[2] . ":" . $this->price[3] . ":" . $this->price[4] . ":" . $this->thePrice . ":" . $this->specialPrice . ":" . $this->qtyBlocks . ":" . $this->taxClass; return $str; } function decode($str) { list($this->productsID, $this->hasQuantityPrice, $this->hasSpecialPrice, $this->quantity[1], $this->quantity[2], $this->quantity[3], $this->quantity[4], $this->price[1], $this->price[2], $this->price[3], $this->price[4], $this->thePrice, $this->specialPrice, $this->qtyBlocks, $this->taxClass) = explode(":", $str); $this->hasQuantityPrice = (($this->hasQuantityPrice == 1) ? true : false); $this->hasSpecialPrice = (($this->hasSpecialPrice == 1) ? true : false); } function parse($prices) { global $customer_group_id, $customer_group_type, $customer_group_discount; if (!tep_not_null($customer_group_id)) { $customer_group_id = VISITOR_PRICING_GROUP; $check_group_query = tep_db_query("select customers_groups_type, customers_groups_discount from " . TABLE_CUSTOMERS_GROUPS . " where customers_groups_id = '" . (int)$customer_group_id . "'"); $check_group = tep_db_fetch_array($check_group_query); $customer_group_type = $check_group['customers_groups_type']; $customer_group_discount = $check_group['customers_groups_discount']; } $this->productsID = $prices['products_id']; $this->hasQuantityPrice=false; $this->hasSpecialPrice=false; // if ($customer_group_type != '1') { // $price_schedule_query = tep_db_query("select products_groups_price, products_groups_price_qty FROM " . TABLE_PRODUCTS_PRICE_SCHEDULES . " WHERE products_id = '" . $prices['products_id'] . "' and customers_groups_id = '" . (int)$customer_group_id . "' and stores_id = '" . STORES_ID . "'"); $price_schedule_query = tep_db_query("select products_groups_price, products_groups_price_qty FROM " . TABLE_PRODUCTS_PRICE_SCHEDULES . " WHERE products_id = '" . $prices['products_id'] . "' and stores_id = '" . STORES_ID . "'"); $this->qtyPriceBreaks = tep_db_num_rows($price_schedule_query); $this->thePrice = $prices['products_price']; $this->specialPrice = $prices['specials_new_products_price']; // } else { // $this->qtyPriceBreaks = 0; // $this->thePrice = $prices['products_price'] * (100 - $customer_group_discount)/100; // $this->specialPrice = $prices['specials_new_products_price']; // if ($this->thePrice < $this->specialPrice) $this->specialPrice = ""; // } $this->hiPrice = $this->thePrice; $this->lowPrice = $this->thePrice; $this->hasSpecialPrice = tep_not_null($this->specialPrice); $this->qtyBlocks = $prices['products_qty_blocks']; $this->taxClass=$prices['products_tax_class_id']; $n = 0; if ($this->qtyPriceBreaks > 0) { while ($price_schedule = tep_db_fetch_array($price_schedule_query)) { $this->price[$n]=$price_schedule['products_groups_price']; $this->quantity[$n]=$price_schedule['products_groups_price_qty']; if ($this->quantity[$n] == '1') { $this->thePrice = $this->price[$n]; $this->hiPrice = $this->thePrice; $this->lowPrice = $this->thePrice; } else { $this->hasQuantityPrice = true; } $n += 1; } } for($i=0; $i<$this->qtyPriceBreaks; $i++) { if ($this->hasSpecialPrice == true) { $this->hiPrice = $this->specialPrice; if ($this->price[$i] > $this->specialPrice) { $this->price[$i] = $this->specialPrice; } } if ($this->hasQuantityPrice == true) { if ($this->price[$i] > $this->hiPrice) { $this->hiPrice = $this->price[$i]; } if ($this->price[$i] < $this->lowPrice) { $this->lowPrice = $this->price[$i]; } } } } function loadProduct($product_id, $language_id=1) { $sql="select pd.products_name, p.products_model, p.products_image, p.products_leadtime, p.products_id, p.manufacturers_id, p.products_price, p.products_weight, p.products_unit, p.products_qty_blocks, p.products_tax_class_id, p.distributors_id, IF(s.status = '1' AND s.stores_id = '" . STORES_ID . "', s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status = '1' AND s.stores_id = '" . STORES_ID . "', s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, ((" . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd) left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id and s.stores_id = '" . STORES_ID . "') INNER JOIN " . TABLE_PRODUCTS_TO_STORES . " p2s ON p.products_id = p2s.products_id where p2s.stores_id = '" . STORES_ID . "' AND p.products_status = '1' and p.products_id = '" . (int)$product_id . "' and pd.products_id = '" . (int)$product_id . "' and pd.language_id = '". (int)$language_id ."'"; $product_info_query = tep_db_query($sql); $product_info = tep_db_fetch_array($product_info_query); $this->parse($product_info); return $product_info; } function computePrice($qty) { $qty = $this->adjustQty($qty); $price = $this->thePrice; if ($this->hasSpecialPrice == true) { $price = $this->specialPrice; } if ($this->hasQuantityPrice == true) { for ($i=0; $i<$this->qtyPriceBreaks; $i++) { if (($this->quantity[$i] > 0) && ($qty >= $this->quantity[$i])) { $price = $this->price[$i]; } } } return $price; } // Force QTY_BLOCKS granularity function adjustQty($qty) { $qb = $this->getQtyBlocks(); if ($qty < 1) { $qty = 0; return $qty; } if ($qb >= 1) { if ($qty < $qb) { $qty = $qb; } if (($qty % $qb) != 0) { $qty += ($qb - ($qty % $qb)); } } return $qty; } function getQtyBlocks() { return $this->qtyBlocks; } function getPrice() { return $this->thePrice; } function getLowPrice() { return $this->lowPrice; } function getHiPrice() { return $this->hiPrice; } function hasSpecialPrice() { return $this->hasSpecialPrice; } function hasQuantityPrice() { return $this->hasQuantityPrice; } function getPriceString($style='productPriceInBox') { global $currencies, $customer_id; // If you want to change the format of the price/quantity table // displayed on the product information page, here is where you do it. if (($this->hasSpecialPrice == true) && ($this->hasQuantityPrice == false)) { $lc_text = ' <s>' . $currencies->display_price($this->thePrice, tep_get_tax_rate($this->taxClass)) . '</s> <span class="productSpecialPrice">' . $currencies->display_price($this->specialPrice, tep_get_tax_rate($this->taxClass)) . '</span>'; } if($this->hasQuantityPrice == true) { $lc_text = '<table align="top" border="0" cellspacing="0" cellpadding="0"><tr><td align="center" colspan="2"><b>' . ($this->hasSpecialPrice == true ? '<s>' . $currencies->display_price($this->thePrice, tep_get_tax_rate($this->taxClass)) . '</s> <span class="productSpecialPrice">' . $currencies->display_price($this->specialPrice, tep_get_tax_rate($this->taxClass)) . '</span> ' : 'vanaf ' . $currencies->display_price($this->lowPrice, tep_get_tax_rate($this->taxClass))) . '</b></td></tr>'; for($i=0; $i<=$this->qtyPriceBreaks; $i++) { if(($this->quantity[$i] > 0) && ($this->price[$i] > $this->specialPrice)) { $lc_text .= '<tr><td class='.$style.' align="right">> ' . $this->quantity[$i] . ' </td><td class='.$style.'>' . $currencies->display_price($this->price[$i], tep_get_tax_rate($this->taxClass)) . '</td></tr>'; } } $lc_text .= '</table>'; } else { if ($this->hasSpecialPrice == true) { $lc_text = ' <s>' . $currencies->display_price($this->thePrice, tep_get_tax_rate($this->taxClass)) . '</s> <span class="productSpecialPrice">' . $currencies->display_price($this->specialPrice, tep_get_tax_rate($this->taxClass)) . '</span>'; } else { $lc_text = ' ' . $currencies->display_price($this->thePrice, tep_get_tax_rate($this->taxClass)) . ''; } } // if (VISITOR_PRICING_GROUP < '0' && !tep_session_is_registered('customer_id')) { // return ''; // } else { return $lc_text; // } } function getPriceStringShort() { global $currencies, $customer_id; if (($this->hasSpecialPrice == true) && ($this->hasQuantityPrice == false)) { $lc_text = '<div class="priceold">' . $currencies->display_price($this->thePrice, tep_get_tax_rate($this->taxClass)) . '</div><div class="pricenew">' . $currencies->display_price($this->specialPrice, tep_get_tax_rate($this->taxClass)) . '</div>'; } elseif ($this->hasQuantityPrice == true) { $lc_text = '<div class="vanaf">vanaf</div><div class="price">' . $currencies->display_price($this->lowPrice, tep_get_tax_rate($this->taxClass)) . ' </div>'; } else { $lc_text = '<div class="price">' . $currencies->display_price($this->thePrice, tep_get_tax_rate($this->taxClass)) . '</div>'; } // if (VISITOR_PRICING_GROUP < '0' && !tep_session_is_registered('customer_id')) { // return TEXT_LOGIN_TO_SEE_PRICES; // } else { return $lc_text; // } } } ?>
: 여기
도움이 필요합니다.
대단히 감사합니다. 매력처럼 작동했기 때문에 ASC 만 DESC로 변경해야했습니다. –