Jump to content

tedmcdonald

Members
  • Content count

    97
  • Joined

  • Last visited

Everything posted by tedmcdonald

  1. tedmcdonald

    Stock Status in Product Listing

    I may have answered my own question. However, perhaps it could be done more elegantly. Here's what I did in product_info.php (actually, in my case, using BTS, the file was catalog/templates/content/product_info.tpl.php): <!--bof stock announcement--> <?php if ((STOCK_CHECK == 'true')&&($product_info['products_quantity'] == 0)) { ?> <tr> <td><span class="markProductOutOfStock"><b>Out of Stock</b></span></td> </tr> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> </tr> <?php } elseif ((STOCK_CHECK == 'true')&&($product_info['products_quantity'] >= 2)&&($product_info['products_quantity'] < 400)) { ?> <tr> <td><span class="markProductOutOfStock"><b>In Stock</b></span></td> </tr> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> </tr> <?php } elseif ((STOCK_CHECK == 'true')&&($product_info['products_quantity'] < -400)&&($product_info['products_quantity'] > -500)) { ?> <tr> <td><span class="markProductOutOfStock"><b>Custom Message Here</b></span></td> </tr> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> </tr> <?php } ?> <!--eof stock announcement--> In this case, items that have a quantity of less than -400 and greater than -500 will display a custom message. I plan on using this to create several different custom messages. Is there any reason why I should NOT do it this way? Best Regards, Ted :thumbsup:
  2. tedmcdonald

    Stock Status in Product Listing

    I have been using this contrib for nearly a year. It is a great contribution. Thank you. I am hoping to expand its usefulness. I would like to expand on the IN STOCK and OUT OF STOCK messages. For example, I would like it to say LOW STOCK when less than 5 items are in stock. Also, I would like to create custom stock messages based on specific stock levels, for example: If stock is between 300 and 400, I would like to have CALL FOR INFO If stock is between 401 and 500, I would like to have ARRIVING IN DECEMBER ETC. There is a contribution called Quantity availability image and text Unlimited that does this, but it is not as conprehensive as this one. Has anyone done anything like this? Can someone give me a hint on how to do this? Best Regards, Ted :-"
  3. tedmcdonald

    USPS Tracking problem

    I have the same problem. Anyone with a solution? Best Regards, Ted
  4. Firstly, thanks for an excellent, and very necessary contribution. :thumbsup: Question: I am testing this contribution and about to release it to my live store. My test involves a customer clicking on Need to return product? in their Order History page. One thing I notice is that the customer's Order History page does not reflect the fact that an item has been requested returned, nor does it show when a return is completed. Is this correct? It seems that the requested return should display in the customer's Order History, right? Am I missing something? :P Best Regards, Ted
  5. tedmcdonald

    Impulse Item

    Howdy Fredrik Any new news to report? I am very surprised that more are not interested in this contribution. It is a great idea. Best, Ted
  6. tedmcdonald

    Google Analytics module

    Clement, thanks for this contribution. :thumbsup: I have a question: My catalog is non-ssl while shopping. When you login and checkout, the customer enters SSL, but it is a different domain. E.g. Person shops at http://shop.com, and checks out at https://secure-shop.com. When I set up my Analytics account, which domain name do I use? Both? Does it matter? Thanks for your help. Best, Ted
  7. I really want to offer a FREE SHIPPING coupon. Is there a way to prevent the coupon user from choosing an expensive (i.e., Overnight) shipping method? Any help greatly appreciated since I am planning on sending out a coupon to all my customers this week. Best Regards, Ted PS. I thought this would have been a common question/problem for others, but I couldn't find a similar thread.
  8. tedmcdonald

    Impulse Item

    Howdy Fredrik :D Anything new to report on Impulse? Let us know. Dangling Carrot IS generating sales for me. Best Regards, Ted
  9. tedmcdonald

    Bundled products

    Thanks Mark Although your solution did not work, the idea that lines might need to be connected led me to find a problem in the checkout_confirmation file where a line did not meet correctly with the line below. Best, Ted
  10. tedmcdonald

    Bundled products

    Thanks for taking a stab at it Sosige, but there is no gap in the actual code. It must just look like it in the quoted code area. Anyone else want to take a stab at my problem (above)? Best Regards, Ted
  11. tedmcdonald

    Bundled products

    On the Order Confirmation page, I get: 1064 - You have an error in your SQL syntax near 'product_id LEFT JOIN products_description pd on p.products_id=pd.products_id whe' at line 2 SELECT pb.subproduct_id, p.products_quantity, pd.products_name from products_bundles pb LEFT JOIN products p on p.products_id=pb.sub product_id LEFT JOIN products_description pd on p.products_id=pd.products_id where pb.bundle_id = '1076' and pd.language_id = '1' under bundled products. I am not able to figure out why. Any ideas, hints? Thanks. Best, Ted My product_info looks thus: <!-- start bundle At the beginning of Bundle Mod Addition 21.01.2005--> <?php if (tep_not_null($product_info['products_bundle'])) { ?> <table border="0" width="65%" cellspacing="1" cellpadding="2" class="infoBox"> <tr class="infoBoxContents"> <td> <table border="0" width="100%" cellspacing="0" cellpadding="2"> <tr> <td class="main" colspan="3"> <?php if ($product_info['products_bundle'] == "yes") { $products_bundle = $product_info['products_bundle']; echo TEXT_PRODUCTS_BY_BUNDLE . "</td></tr>"; $bundle_query = tep_db_query(" SELECT pd.products_name, pb.*, p.products_bundle, p.products_id, p.products_price, p.products_image FROM products p INNER JOIN " . TABLE_PRODUCTS_DESCRIPTION . " pd ON p.products_id=pd.products_id INNER JOIN " . TABLE_PRODUCTS_BUNDLES . " pb ON pb.subproduct_id=pd.products_id WHERE pb.bundle_id = " . (int)$HTTP_GET_VARS['products_id'] . " and language_id = '" . (int)$languages_id . "'"); while ($bundle_data = tep_db_fetch_array($bundle_query)) { if ($bundle_data['products_bundle'] == "yes") { // uncomment the following line to display subproduct qty echo "<br>? <b>" . $bundle_data['subproduct_qty'] . " x " . $bundle_data['products_name'] . "</b>"; echo "<br>? <b> " . $bundle_data['products_name'] . "</b>"; $bundle_query_nested = tep_db_query(" SELECT pd.products_name, pb.*, p.products_bundle, p.products_id, p.products_price FROM products p INNER JOIN " . TABLE_PRODUCTS_DESCRIPTION . " pd ON p.products_id=pd.products_id INNER JOIN " . TABLE_PRODUCTS_BUNDLES . " pb ON pb.subproduct_id=pd.products_id WHERE pb.bundle_id = " . $bundle_data['products_id'] . " and language_id = '" . (int)$languages_id . "'");
  12. tedmcdonald

    Official thread for Great Categories

    Yep, that was it. :D I had to add: // #################### Added Enable / Disable Categories ############## // $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '0' and c.categories_id = cd.categories_id and cd.language_id='" . (int)$languages_id ."' order by sort_order, cd.categories_name"); $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '0' and c.categories_id = cd.categories_id and cd.language_id='" . (int)$languages_id ."' and c.categories_status = '1' order by sort_order, cd.categories_name"); // #################### End Added Enable / Disable Categories ############## to both queries. Best, Ted
  13. tedmcdonald

    Bundled products

    Ouch! :blink: I just found a problem at checkout for my only bundled product. On the Order Confirmation page, I get: What's wrong? Please help if you can. Best Regards, Ted
  14. tedmcdonald

    Bundled products

    By the way, the solution works for the Extra Fields Contribution...thus: // START: Extra Fields Contribution v2.0b $extra_fields_query = tep_db_query(" SELECT pef.products_extra_fields_status as status, pef.products_extra_fields_name as name, ptf.products_extra_fields_value as value FROM ". TABLE_PRODUCTS_EXTRA_FIELDS ." pef LEFT JOIN ". TABLE_PRODUCTS_TO_PRODUCTS_EXTRA_FIELDS ." ptf ON ptf.products_extra_fields_id=pef.products_extra_fields_id WHERE ptf.products_id=".[b](int)[/b]$HTTP_GET_VARS['products_id']." and ptf.products_extra_fields_value<>'' and (pef.languages_id='0' or pef.languages_id='".$languages_id."') ORDER BY products_extra_fields_order"); Best Regards, Ted
  15. tedmcdonald

    Official thread for Great Categories

    Fantastic contribution. :thumbsup: Thank you! I do have one problem though: I am using enable_disable_categories_1.6.1.1 My disabled categories still show up in Great Categories. Any idea why? Best Regards, Ted
  16. tedmcdonald

    Bundled products

    Howdy Folks I would like to have my Bundled Products listed also as Specials. Currently, if I add a bundled product to Specials, it's special price is not correct in the You save... line. Here's what I did: I added a bundled product with three products @ $5.00 each. I made the bundled product price $15.00 (no savings), and then I put the bundled product on Special at $10.00. I was hoping it would then say You save $5.00, but it doesn't. Is it possible to have a Bundled Product also be on Special and the price that you save accurate? :huh: Please let me know if you know. :) Best, Ted
  17. tedmcdonald

    Bundled Products

    I am running it successfully on CRE 6.15. Didn't do anything special to set it up. Just followed the installation directions. Best, Ted
  18. tedmcdonald

    [Contribution] Tabbed Product Pages

    :P I had no idea. Do you know what he calls it? Do you know his user name? Thanks. Best, Ted
  19. tedmcdonald

    [Contribution] Tabbed Product Pages

    :thumbsup: Yep, that worked. Thanks a lot. I am sure it will be helpful for a lot of others. As far as the Options/Attributes not showing up unless they exist. In product_info.tpl.php, my tab code for my second tab "Options" starts like this: <!-- Tab2 Start --> <div class="tab-page" id="tabPage2"> <h2 class="tab"><?php echo TAB_OPTIONS;?></h2> <script type="text/javascript">tp1.addTabPage( document.getElementById( "tabPage2" ) );</script> <table><tr><td class="main"> <?php $products_attributes_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP _GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "'"); $products_attributes = tep_db_fetch_array($products_attributes_query); if ($products_attributes['total'] > 0) { And ends like this: echo '<table border="0" cellspacing="0" cellpadding="2" width="100%" height="100"> <tr> <td class="main" colspan="2"><b>' . NO_TEXT_PRODUCT_OPTIONS . '</b></td> </tr></table>'; } ?> <?php } // otf 1.71 end if ?> </td> </tr> </td></tr></table> </div> <!-- Tab2 End --> ...and has a lot of modified code in between. I have it so that Extra photos will show up if there are extra photos, and the Manufacturer will show up if there is a manufacturer, but the Options (attributes) tab shows up everytime. Image example: // No need to show this tab, if there are no extra images and Ultra Images Pack disabled. if (ULTIMATE_ADDITIONAL_IMAGES == 'enable') { if (tep_not_null($product_info['products_image_sm_1'])) { ?> <!-- Tab3 Start --> <div class="tab-page" id="tabPage3"> <h2 class="tab"><?php echo TAB_EXTRA_IMAGES;?></h2> <script type="text/javascript">tp1.addTabPage( document.getElementById( "tabPage3" ) );</script> <table><tr><td class="main"> <?php // BOF MaxiDVD: Modified For Ultimate Images Pack! include(DIR_WS_MODULES . 'additional_images.php'); // BOF MaxiDVD: Modified For Ultimate Images Pack! ?> </td> </tr> </table> </div> <!-- Tab3 End --> Oh, did I mention, I am using a modified version of Tabbed Product Pages that works with CRE 6.15...Yep! ;) Best, Ted
  20. tedmcdonald

    [Contribution] Tabbed Product Pages

    Anyone have any luck finding a way to have it default back to Description when selecting a different item? This is very important!!! :o Also, does anyone know how to have the Options tab hide if there are no options? Any help greatly appreciated. Best, Ted
  21. tedmcdonald

    Impulse Item

    Okay, that makes sense. :thumbsup: I think that there should be an option to get more info if necessary. I have had some success with Dangling Carrot, so the concept is workable. I really think that the Dangling Carrot concept whereby the customer feels as if she is being rewarded for buying...that's a good concept, i.e., "By spending over $19.00 you have qualified for the following Special Offer!" Dangling Carrot's biggest problem is the inability to buy multiple specials. I know I will get even more sales if I can get a workable Dangling/Impulse :lol: Best, Ted
  22. tedmcdonald

    Problem with e Products Extra Field

    :( Is this thread still going? I have temporarily solved the above problem by simply adding a backslash (\) to any apostrophe ('). New Problem: :P When I try to copy or duplicate an item, the Extra Fields to not copy over to the new item. Why? :huh: Please answer if you can. Best Regards, Ted
  23. tedmcdonald

    Impulse Item

    Howdy Fredrik That worked! Thanks. :lol: The next important change is to have it so that the customer can click on the item and go to the product info page rather than just seeing an enlarged photo. I think that most customers are going to want to learn more about a product before they buy; furthermore, they will be back in the store where they might find yet another item, too. Best Regards, Ted PS. I think that it would be great to merge some of the Dangling Carrot concepts with Impulse Item
  24. tedmcdonald

    Impulse Item

    Howdy Fredrik Oh yes, combining this with Dangling Carrot would be a fantastic tool, and yes, I am sure it will bring in more sales; however, I have not tested your contribution on a live site yet. Actually, on my catalog side, the following code: $specials_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . (int)$prid . "' and status = '1'"); if (tep_db_num_rows ($specials_query)) { $specials = tep_db_fetch_array($specials_query); $products_price = $specials['specials_new_products_price']; } is in my functions/general.php file. Also, your instructions have this marked twice: ================================================== 3. Open catalog/includes/classes/shopping_cart.php ================================================== FIND: $specials_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . (int)$prid . "' and status = '1'"); if (tep_db_num_rows ($specials_query)) { $specials = tep_db_fetch_array($specials_query); $products_price = $specials['specials_new_products_price']; } ADD AFTER: //Impulse Item by jfj $specials_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS_CHECKOUT . " where products_id = '" . (int)$prid . "' and status = '1'"); if (tep_db_num_rows ($specials_query)) { $specials = tep_db_fetch_array($specials_query); $products_price = $specials['specials_new_products_price']; } //Impulse Item by jfj FIND: $specials_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . (int)$prid . "' and status = '1'"); if (tep_db_num_rows($specials_query)) { $specials = tep_db_fetch_array($specials_query); $products_price = $specials['specials_new_products_price']; } ADD AFTER: //Impulse Item by jfj $specials_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS_CHECKOUT . " where products_id = '" . (int)$prid . "' and status = '1'"); if (tep_db_num_rows($specials_query)) { $specials = tep_db_fetch_array($specials_query); $products_price = $specials['specials_new_products_price']; } //Impulse Item by jfj However, I only find it once. My catalog/includes/classes/shopping_cart.php looks like this (sorry it is so long): <?php /* $Id: shopping_cart.php,v 1.1.1.1 2004/03/04 23:40:47 ccwjr Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2003 osCommerce Released under the GNU General Public License */ class shoppingCart { var $contents, $total, $weight, $cartID, $content_type; function shoppingCart() { $this->reset(); } function restore_contents() { //ICW replace line global $customer_id, $gv_id, $REMOTE_ADDR; // global $customer_id; if (!tep_session_is_registered('customer_id')) return false; // insert current cart contents in database if (is_array($this->contents)) { reset($this->contents); while (list($products_id, ) = each($this->contents)) { $qty = $this->contents[$products_id]['qty']; $product_query = tep_db_query("select products_id from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'"); if (!tep_db_num_rows($product_query)) { tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET . " (customers_id, products_id, customers_basket_quantity, customers_basket_date_added) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . $qty . "', '" . date('Ymd') . "')"); if (isset($this->contents[$products_id]['attributes'])) { reset($this->contents[$products_id]['attributes']); while (list($option, $value) = each($this->contents[$products_id]['attributes'])) { // otf 1.71 Update query to include attribute value. This is needed for text attributes. $attr_value = $this->contents[$products_id]['attributes_values'][$option]; tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_id, products_id, products_options_id, products_options_value_id, products_options_value_text) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . (int)$option . "', '" . (int)$value . "', '" . tep_db_input($attr_value) . "')"); } } } else { tep_db_query("update " . TABLE_CUSTOMERS_BASKET . " set customers_basket_quantity = '" . $qty . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'"); } } //ICW ADDDED FOR CREDIT CLASS GV - START if (tep_session_is_registered('gv_id')) { $gv_query = tep_db_query("insert into " . TABLE_COUPON_REDEEM_TRACK . " (coupon_id, customer_id, redeem_date, redeem_ip) values ('" . $gv_id . "', '" . (int)$customer_id . "', now(),'" . $REMOTE_ADDR . "')"); $gv_update = tep_db_query("update " . TABLE_COUPONS . " set coupon_active = 'N' where coupon_id = '" . $gv_id . "'"); tep_gv_account_update($customer_id, $gv_id); tep_session_unregister('gv_id'); } //ICW ADDDED FOR CREDIT CLASS GV - END } // reset per-session cart contents, but not the database contents $this->reset(false); $products_query = tep_db_query("select products_id, customers_basket_quantity from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "'"); while ($products = tep_db_fetch_array($products_query)) { $this->contents[$products['products_id']] = array('qty' => $products['customers_basket_quantity']); // attributes // otf 1.71Update query to pull attribute value_text. This is needed for text attributes. $attributes_query = tep_db_query("select products_options_id, products_options_value_id, products_options_value_text from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products['products_id']) . "'"); while ($attributes = tep_db_fetch_array($attributes_query)) { $this->contents[$products['products_id']]['attributes'][$attributes['products_options_id']] = $attributes['products_options_value_id']; // If text attribute, then set additional information if ($attributes['products_options_value_id'] == PRODUCTS_OPTIONS_VALUE_TEXT_ID) { $this->contents[$products['products_id']]['attributes_values'][$attributes['products_options_id']] = $attributes['products_options_value_text']; } } } $this->cleanup(); } function reset($reset_database = false) { global $customer_id; $this->contents = array(); $this->total = 0; $this->weight = 0; $this->content_type = false; if (tep_session_is_registered('customer_id') && ($reset_database == true)) { tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "'"); tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "'"); } unset($this->cartID); if (tep_session_is_registered('cartID')) tep_session_unregister('cartID'); } function add_cart($products_id, $qty = '1', $attributes = '', $notify = true) { global $new_products_id_in_cart, $customer_id; $products_id = tep_get_uprid($products_id, $attributes); if ($notify == true) { $new_products_id_in_cart = $products_id; tep_session_register('new_products_id_in_cart'); } if ($this->in_cart($products_id)) { $this->update_quantity($products_id, $qty, $attributes); } else { $this->contents[] = array($products_id); $this->contents[$products_id] = array('qty' => $qty); // insert into database if (tep_session_is_registered('customer_id')) tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET . " (customers_id, products_id, customers_basket_quantity, customers_basket_date_added) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . $qty . "', '" . date('Ymd') . "')"); if (is_array($attributes)) { reset($attributes); while (list($option, $value) = each($attributes)) { // otf 1.71 Check if input was from text box. If so, store additional attribute information // Check if text input is blank, if so do not add to attribute lists // Add htmlspecialchars processing. This handles quotes and other special chars in the user input. $attr_value = NULL; $blank_value = FALSE; if (strstr($option, TEXT_PREFIX)) { if (trim($value) == NULL) { $blank_value = TRUE; } else { $option = substr($option, strlen(TEXT_PREFIX)); $attr_value = htmlspecialchars(stripslashes($value), ENT_QUOTES); $value = PRODUCTS_OPTIONS_VALUE_TEXT_ID; $this->contents[$products_id]['attributes_values'][$option] = $attr_value; } } if (!$blank_value) { $this->contents[$products_id]['attributes'][$option] = $value; // insert into database // otf 1.71 Update db insert to include attribute value_text. This is needed for text attributes. // Add tep_db_input() processing if (tep_session_is_registered('customer_id')) tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_id, products_id, products_options_id, products_options_value_id, products_options_value_text) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . (int)$option . "', '" . (int)$value . "', '" . tep_db_input($attr_value) . "')"); } } } } $this->cleanup(); // assign a temporary unique ID to the order contents to prevent hack attempts during the checkout procedure $this->cartID = $this->generate_cart_id(); } function update_quantity($products_id, $quantity = '', $attributes = '') { global $customer_id; if (empty($quantity)) return true; // nothing needs to be updated if theres no quantity, so we return true.. $this->contents[$products_id] = array('qty' => $quantity); // update database if (tep_session_is_registered('customer_id')) tep_db_query("update " . TABLE_CUSTOMERS_BASKET . " set customers_basket_quantity = '" . $quantity . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'"); if (is_array($attributes)) { reset($attributes); while (list($option, $value) = each($attributes)) { // otf 1.71 Check if input was from text box. If so, store additional attribute information // Check if text input is blank, if so do not update attribute lists // Add htmlspecialchars processing. This handles quotes and other special chars in the user input. $attr_value = NULL; $blank_value = FALSE; if (strstr($option, TEXT_PREFIX)) { if (trim($value) == NULL) { $blank_value = TRUE; } else { $option = substr($option, strlen(TEXT_PREFIX)); $attr_value = htmlspecialchars(stripslashes($value), ENT_QUOTES); $value = PRODUCTS_OPTIONS_VALUE_TEXT_ID; $this->contents[$products_id]['attributes_values'][$option] = $attr_value; } } if (!$blank_value) { $this->contents[$products_id]['attributes'][$option] = $value; // update database // Update db insert to include attribute value_text. This is needed for text attributes. // Add tep_db_input() processing if (tep_session_is_registered('customer_id')) tep_db_query("update " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " set products_options_value_id = '" . (int)$value . "', products_options_value_text = '" . tep_db_input($attr_value) . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "' and products_options_id = '" . (int)$option . "'"); } } } } function cleanup() { global $customer_id; reset($this->contents); while (list($key,) = each($this->contents)) { if ($this->contents[$key]['qty'] < 1) { unset($this->contents[$key]); // remove from database if (tep_session_is_registered('customer_id')) { tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($key) . "'"); tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($key) . "'"); } } } } function count_contents() { // get total number of items in cart $total_items = 0; if (is_array($this->contents)) { reset($this->contents); while (list($products_id, ) = each($this->contents)) { $total_items += $this->get_quantity($products_id); } } return $total_items; } function get_quantity($products_id) { if (isset($this->contents[$products_id])) { return $this->contents[$products_id]['qty']; } else { return 0; } } function in_cart($products_id) { if (isset($this->contents[$products_id])) { return true; } else { return false; } } function remove($products_id) { global $customer_id; // otf 1.71 Add call tep_get_uprid to correctly format product ids containing quotes $products_id = tep_get_uprid($products_id, $attributes); unset($this->contents[$products_id]); // remove from database if (tep_session_is_registered('customer_id')) { tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'"); tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'"); } // assign a temporary unique ID to the order contents to prevent hack attempts during the checkout procedure $this->cartID = $this->generate_cart_id(); } function remove_all() { $this->reset(); } function get_product_id_list() { $product_id_list = ''; if (is_array($this->contents)) { reset($this->contents); while (list($products_id, ) = each($this->contents)) { $product_id_list .= ', ' . $products_id; } } return substr($product_id_list, 2); } function calculate() { $this->total_virtual = 0; // ICW Gift Voucher System $this->total = 0; $this->weight = 0; if (!is_array($this->contents)) return 0; reset($this->contents); while (list($products_id, ) = each($this->contents)) { $qty = $this->contents[$products_id]['qty']; // products price $product_query = tep_db_query("select products_id, products_price, products_tax_class_id, products_weight from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'"); if ($product = tep_db_fetch_array($product_query)) { // ICW ORDER TOTAL CREDIT CLASS Start Amendment $no_count = 1; $gv_query = tep_db_query("select products_model from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'"); $gv_result = tep_db_fetch_array($gv_query); if (ereg('^GIFT', $gv_result['products_model'])) { $no_count = 0; } // ICW ORDER TOTAL CREDIT CLASS End Amendment $prid = $product['products_id']; $products_tax = tep_get_tax_rate($product['products_tax_class_id']); $products_price = $product['products_price']; $products_weight = $product['products_weight']; $special_price = tep_get_products_special_price($prid); if ($special_price) { $products_price = $special_price; } $this->total_virtual += tep_add_tax($products_price, $products_tax) * $qty * $no_count;// ICW CREDIT CLASS; $this->weight_virtual += ($qty * $products_weight) * $no_count;// ICW CREDIT CLASS; $this->total += tep_add_tax($products_price, $products_tax) * $qty; $this->weight += ($qty * $products_weight); } // attributes price if (isset($this->contents[$products_id]['attributes'])) { reset($this->contents[$products_id]['attributes']); while (list($option, $value) = each($this->contents[$products_id]['attributes'])) { $attribute_price_query = tep_db_query("select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$prid . "' and options_id = '" . (int)$option . "' and options_values_id = '" . (int)$value . "'"); $attribute_price = tep_db_fetch_array($attribute_price_query); if ($attribute_price['price_prefix'] == '+') { $this->total += $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax); } else { $this->total -= $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax); } } } } } function attributes_price($products_id) { $attributes_price = 0; if (isset($this->contents[$products_id]['attributes'])) { reset($this->contents[$products_id]['attributes']); while (list($option, $value) = each($this->contents[$products_id]['attributes'])) { $attribute_price_query = tep_db_query("select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$products_id . "' and options_id = '" . (int)$option . "' and options_values_id = '" . (int)$value . "'"); $attribute_price = tep_db_fetch_array($attribute_price_query); if ($attribute_price['price_prefix'] == '+') { $attributes_price += $attribute_price['options_values_price']; } else { $attributes_price -= $attribute_price['options_values_price']; } } } return $attributes_price; } function get_products() { global $languages_id; if (!is_array($this->contents)) return false; $products_array = array(); reset($this->contents); while (list($products_id, ) = each($this->contents)) { // $products_query = tep_db_query("select p.products_id, pd.products_name, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_tax_class_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . (int)$products_id . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'"); $products_query = tep_db_query("select p.products_id, pd.products_name, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_carrot, p.products_tax_class_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . (int)$products_id . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'"); if ($products = tep_db_fetch_array($products_query)) { $prid = $products['products_id']; $products_price = $products['products_price']; $special_price = tep_get_products_special_price($prid); if ($special_price) { $products_price = $special_price; } // otf 1.71 Update $products_array to include attribute value_text. This is needed for text attributes. $products_array[] = array('id' => $products_id, 'name' => $products['products_name'], 'model' => $products['products_model'], 'image' => $products['products_image'], 'price' => $products_price, 'quantity' => $this->contents[$products_id]['qty'], 'weight' => $products['products_weight'], 'carrot' => $products['products_carrot'], 'final_price' => ($products_price + $this->attributes_price($products_id)), 'tax_class_id' => $products['products_tax_class_id'], 'attributes' => (isset($this->contents[$products_id]['attributes']) ? $this->contents[$products_id]['attributes'] : ''), 'attributes_values' => (isset($this->contents[$products_id]['attributes_values']) ? $this->contents[$products_id]['attributes_values'] : '')); } } return $products_array; } function show_total() { $this->calculate(); return $this->total; } function show_weight() { $this->calculate(); return $this->weight; } // CREDIT CLASS Start Amendment function show_total_virtual() { $this->calculate(); return $this->total_virtual; } function show_weight_virtual() { $this->calculate(); return $this->weight_virtual; } // CREDIT CLASS End Amendment function generate_cart_id($length = 5) { return tep_create_random_value($length, 'digits'); } function get_content_type() { $this->content_type = false; if ( (DOWNLOAD_ENABLED == 'true') && ($this->count_contents() > 0) ) { reset($this->contents); while (list($products_id, ) = each($this->contents)) { if (isset($this->contents[$products_id]['attributes'])) { reset($this->contents[$products_id]['attributes']); while (list(, $value) = each($this->contents[$products_id]['attributes'])) { $virtual_check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad where pa.products_id = '" . (int)$products_id . "' and pa.options_values_id = '" . (int)$value . "' and pa.products_attributes_id = pad.products_attributes_id"); $virtual_check = tep_db_fetch_array($virtual_check_query); if ($virtual_check['total'] > 0) { switch ($this->content_type) { case 'physical': $this->content_type = 'mixed'; return $this->content_type; break; default: $this->content_type = 'virtual'; break; } } else { switch ($this->content_type) { case 'virtual': $this->content_type = 'mixed'; return $this->content_type; break; default: $this->content_type = 'physical'; break; } } } // ICW ADDED CREDIT CLASS - Begin } elseif ($this->show_weight() == 0) { reset($this->contents); while (list($products_id, ) = each($this->contents)) { $virtual_check_query = tep_db_query("select products_weight from " . TABLE_PRODUCTS . " where products_id = '" . $products_id . "'"); $virtual_check = tep_db_fetch_array($virtual_check_query); if ($virtual_check['products_weight'] == 0) { switch ($this->content_type) { case 'physical': $this->content_type = 'mixed'; return $this->content_type; break; default: $this->content_type = 'virtual_weight'; break; } } else { switch ($this->content_type) { case 'virtual': $this->content_type = 'mixed'; return $this->content_type; break; default: $this->content_type = 'physical'; break; } } } // ICW ADDED CREDIT CLASS - End } else { switch ($this->content_type) { case 'virtual': $this->content_type = 'mixed'; return $this->content_type; break; default: $this->content_type = 'physical'; break; } } } } else { $this->content_type = 'physical'; } return $this->content_type; } function unserialize($broken) { for(reset($broken);$kv=each($broken);) { $key=$kv['key']; if (gettype($this->$key)!="user function") $this->$key=$kv['value']; } } // ------------------------ ICWILSON CREDIT CLASS Gift Voucher Addittion-------------------------------Start // amend count_contents to show nil contents for shipping // as we don't want to quote for 'virtual' item // GLOBAL CONSTANTS if NO_COUNT_ZERO_WEIGHT is true then we don't count any product with a weight // which is less than or equal to MINIMUM_WEIGHT // otherwise we just don't count gift certificates function count_contents_virtual() { // get total number of items in cart disregard gift vouchers $total_items = 0; if (is_array($this->contents)) { reset($this->contents); while (list($products_id, ) = each($this->contents)) { $no_count = false; $gv_query = tep_db_query("select products_model from " . TABLE_PRODUCTS . " where products_id = '" . $products_id . "'"); $gv_result = tep_db_fetch_array($gv_query); if (ereg('^GIFT', $gv_result['products_model'])) { $no_count=true; } if (NO_COUNT_ZERO_WEIGHT == 1) { $gv_query = tep_db_query("select products_weight from " . TABLE_PRODUCTS . " where products_id = '" . tep_get_prid($products_id) . "'"); $gv_result=tep_db_fetch_array($gv_query); if ($gv_result['products_weight']<=MINIMUM_WEIGHT) { $no_count=true; } } if (!$no_count) $total_items += $this->get_quantity($products_id); } } return $total_items; } // ------------------------ ICWILSON CREDIT CLASS Gift Voucher Addittion-------------------------------End } ?> The section in my catalog/includes/functions/general.php looks thus: //// // Return a product's special price (returns nothing if there is no offer) // TABLES: products function tep_get_products_special_price($product_id) { $product_query = tep_db_query("select products_price, products_model from " . TABLE_PRODUCTS . " where products_id = '" . $product_id . "'"); if (tep_db_num_rows($product_query)) { $product = tep_db_fetch_array($product_query); $product_price = $product['products_price']; } else { return false; } $specials_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . $product_id . "' and status"); if (tep_db_num_rows($specials_query)) { $special = tep_db_fetch_array($specials_query); $special_price = $special['specials_new_products_price']; } else { $special_price = false; } //Impulse Item by jfj $specials_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS_CHECKOUT . " where products_id = '" . (int)$prid . "' and status = '1'"); if (tep_db_num_rows($specials_query)) { $specials = tep_db_fetch_array($specials_query); $products_price = $specials['specials_new_products_price']; } //Impulse Item by jfj if(substr($product['products_model'], 0, 4) == 'GIFT') { //Never apply a salededuction to Ian Wilson's Giftvouchers return $special_price; } $product_to_categories_query = tep_db_query("select categories_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . $product_id . "'"); $product_to_categories = tep_db_fetch_array($product_to_categories_query); Any ideas? By the way, my regular speicals.php works fine, and the correct specials_checkout.php price is being added to the database. Best Regards, Ted
  25. tedmcdonald

    Impulse Item

    Howdy Redrum Great contribution! :D I am testing it now. I am running it with along with Dangling Carrot 2.0 I have a couple questions: When I select the Special Offer at checkout, it shows up in the Shopping Cart at it's regular price. For example, regular price is $49.95, I give it a Specials Offer price as $39.95. It shows up accurately at $39.95, yet when I Buy It Now, it shows up in the Cart as $49.95. Why? Let me know if you know. Best, Ted
×