Jump to content

disco_ii_disco

Member
  • Posts

    115
  • Joined

  • Last visited

Everything posted by disco_ii_disco

  1. Another great tip. A line of code which I will use a lot, going forward. I inserted the debug code and there is no change in the stock_level at the beginning, middle or end of my code snippet. It is always showing the out of date stock level. Therefore, the problem is before it gets to the code snippet. The below example had been updated, via the API, to show a stock level of 13: [0] At line 3, the stock_status is: True [1] At line 5, the stock_level is: 12 [2] The stock_status is: True [3] The stock_level is: 12 [4] The stock_level_supplier is: 0 [5] The stock_level_shop is: 5 [6] The stock_level_warehouse is: 7 [7] At line 60, the stock_status is: True [8] At line 62, the stock_level is: 12
  2. All SQL queries that contain stock_level information, both in the Cubecart tables and the custom table, are not cached (as confirmed by the debug section). 16. Hack: 1626816962.30120 --- Duration: 264 µs [NOT CACHED] SELECT `stock_level`, `product_code`, `upc`, `jan`, `isbn`, `image` FROM `CubeCart_option_matrix` WHERE CubeCart_option_matrix.product_id = '1008' AND CubeCart_option_matrix.options_identifier IS NULL AND CubeCart_option_matrix.status = '1' ; 21. Hack: 1626816962.30170 --- Duration: 176 µs [NOT CACHED] SELECT `stock_level`, `product_code`, `upc`, `jan`, `isbn`, `image` FROM `CubeCart_option_matrix` WHERE CubeCart_option_matrix.product_id = '1008' AND CubeCart_option_matrix.options_identifier IS NULL AND CubeCart_option_matrix.status = '1' ; 24. Hack: 1626816962.30250 --- Duration: 282 µs [NOT CACHED] SELECT SQL_CALC_FOUND_ROWS MAX(stock_level) AS `stock_level` FROM `CubeCart_option_matrix` WHERE CubeCart_option_matrix.product_id = '1008' AND CubeCart_option_matrix.status = '1' AND CubeCart_option_matrix.use_stock = '1' LIMIT 1; 25. Hack: 1626816962.30280 --- Duration: 206 µs [NOT CACHED] SELECT SQL_CALC_FOUND_ROWS `stock_level` FROM `CubeCart_inventory` WHERE CubeCart_inventory.product_id = '1008' LIMIT 1; 75. Hack: 1626816962.30830 --- Duration: 499 µs [NOT CACHED] SELECT `stock_level` FROM `stock_levels` WHERE stock_levels.product_id = '1008' AND stock_levels.location_id = '1' ORDER BY location_id ; 131. Hack: 1626816962.34640 --- Duration: 567 µs [NOT CACHED] SELECT SQL_CALC_FOUND_ROWS `stock_level` FROM `CubeCart_inventory` WHERE CubeCart_inventory.product_id = '7552' LIMIT 1;
  3. Yes, when "Enabling Caching" is set to "disabled" (in admin) it fixes the problem: The debug information and the stock level information on the page display correctly. Once caching is turned back on, the out of date information is then displayed - until the cache is cleared.
  4. Thank you for the debug code tip - I'll use this a lot going forward. Here is an example output: [0] The stock_status is: True [1] The stock_level is: 17 [2] The stock_level_supplier is: 0 [3] The stock_level_shop is: 17 [4] The stock_level_warehouse is: 0 Then... I made a change to the stock level for this product, in my system; I updated Cubecart via my API; I checked the stock change had been applied in database (it was also showing correctly in Cubecart admin); I reloaded the product page (on two different computers). No change to the stock levels were shown on either computer. The debug information was exactly the same as above (i.e before the change). I cleared the cache and refreshed the page. Stock level change shown.
  5. The problem I am having must be due to this part of the code: $GLOBALS['smarty']->assign('STOCK_STATUS', $stock_status, true); $GLOBALS['smarty']->assign('STOCK_LEVEL', $stock_level, true); $GLOBALS['smarty']->assign('STOCK_LEVEL_SUPPLIER', $stock_level_supplier, true); $GLOBALS['smarty']->assign('STOCK_LEVEL_SHOP', $stock_level_shop, true); $GLOBALS['smarty']->assign('STOCK_LEVEL_WAREHOUSE', $stock_level_warehouse, true); There shouldn't be a situation where where product_id is A and location_id is B. I wrote it like this so you can query by different location ids. (Most of the code was reused from parts of the catalagoue class). $product['available_to_order'] is an integer field I have in my inventory table, that gets updated through my API.
  6. Here is the code snippet: <?php if ((bool)$product['use_stock_level']) { $stock_level_supplier = $product['available_to_order']; $stock_level_warehouse = (int)$GLOBALS['chris']->getProductLocationStockLevel ($product['product_id'], 1); //(int)$stock_level already defined in catalogue.class.php $stock_level_shop = $stock_level - (int)$stock_level_warehouse; //there could be a higher stock level at shop than the actual stock_level (due to stock ready to be transferred for web orders) - so reduce the stock level accordingly... if ($stock_level_shop > $stock_level) $stock_level_shop = $stock_level; //$stock_level already defined in catalogue.class.php if ($stock_level <= 0) { // Out of Stock if (!$GLOBALS['config']->get('config', 'basket_out_of_stock_purchase')) { // Not Allowed $allow_purchase = false; $out = true; } $stock_level_status = ($product['available_to_order']>0 || $stock_level_supplier>0) ? 1 : 0; $in_stock_at_warehouse = 0; $in_stock_at_shop = 0; } else { $stock_level_status = 1; $in_stock_at_warehouse = ($stock_level_warehouse>0) ? 1 : 0; $in_stock_at_shop = ($stock_level_shop>0) ? 1 : 0; } //added true to prevent caching 4/7/21 $GLOBALS['smarty']->assign('STOCK_STATUS', $stock_status, true); $GLOBALS['smarty']->assign('STOCK_LEVEL', $stock_level, true); $GLOBALS['smarty']->assign('STOCK_LEVEL_SUPPLIER', $stock_level_supplier, true); $GLOBALS['smarty']->assign('STOCK_LEVEL_SHOP', $stock_level_shop, true); $GLOBALS['smarty']->assign('STOCK_LEVEL_WAREHOUSE', $stock_level_warehouse, true); $GLOBALS['smarty']->assign('IN_STOCK_AT_WAREHOUSE', $in_stock_at_warehouse, true); $GLOBALS['smarty']->assign('IN_STOCK_AT_SHOP', $in_stock_at_shop, true); } ?> And the function to get the location stock level is just: public function getProductLocationStockLevel ($product_id, $location_id=1) { if (($stock_level_at_location = $GLOBALS['db']->select('stock_levels', array('stock_level'), array('product_id' => (int)$product_id, 'location_id' => $location_id), 'location_id', false, 1, false)) !== false) { $qty_at_location = $stock_level_at_location[0]['stock_level']; } else { $qty_at_location = 0; } return $qty_at_location; }
  7. I am presuming my code snippet, which runs at class.cubecart.display_product, is saving the variables, and not refreshing: $GLOBALS['smarty']->assign('STOCK_LEVEL_SUPPLIER', $stock_level_supplier, true); $GLOBALS['smarty']->assign('STOCK_LEVEL_SHOP', $stock_level_shop, true); $GLOBALS['smarty']->assign('STOCK_LEVEL_WAREHOUSE', $stock_level_warehouse, true); I added the true part recently, as this is supposed to save as a nocache variable: https://www.smarty.net/docs/en/caching.cacheable.tpl
  8. I think if I can just find a way of knowing the name of the cache file, I can delete the file when my API updates the stock.
  9. Same result when manually changing values (in phpMyAdmin) or using my API.
  10. The query is not being cached: Duration: 425 µs [NOT CACHED] SELECT `stock_level` FROM `stock_levels` WHERE stock_levels.product_id = '11262' AND stock_levels.location_id = '1'; The cache/skin file looks fine. It must be the Smarty template variables that are being cached(?) from the code snippet.
  11. Nothing concerning! "Different locations" meant a table I have that stores the stock levels at each physical location: e.g: location_id, product_id, stock_level. The query to get the data, in my code snippet, is the same as the Cubecart getProductStock() code but it looks in my stock_levels table rather than the inventory table. The overall stock level is still stored in the inventory table.
  12. Thank you for your reply bsmither. That has given me a lot more understanding of what is going on. You are right, the text on the product page is coming from a code snippet. The cope snippet: Looks up stock levels in different locations (I have double checked to make sure this query has the cache value set to false) Assigns some smarty variables based on the stock status The text then changes on the product template changes based on the stock status (i.e whether the product is in stock at our shop, our warehouse or only with our suppliers). I am guessing it is the smarty part that is being cached. Is there a way to prevent this, or do you think I'd be better using the unlink method? I have tried assigning the variables as nocache variables and have also tried adding {nocache} {/nocache} to the relevent section of the template. Neither of these solved my problem. https://www.smarty.net/docs/en/caching.cacheable.tpl
  13. Thank you for the reply Noodleman. I have found the code that the admin system uses for clearing the entire cache: if (isset($_GET['clear_cache']) && $_GET['clear_cache'] == 'true') { $GLOBALS['cache']->clear(); $GLOBALS['session']->delete('CLEAR_CACHE'); $GLOBALS['main']->successMessage($GLOBALS['language']->maintain['notify_cache_cleared'], false); httpredir(currentPage(array('clear_cache'))); } Is it possible to clear the cache for a single product? I am guessing not - otherwise this would happen after updating a product in admin.
  14. I have built an API for my CubeCart store to update the stock levels from my till and stock management system. It is working well. However, sometimes old stock levels are being displayed on product pages. I have to keep going in to clear the cache from the Cubecart admin to fix it. Does anyone know a way around this? Is there a way to clear the cache for an individual product? (I am not completely sure how the cache works!) If so, I could do this in the API.
  15. Hi Josh, I was fortunate enough to launch my website 15 years ago - when things were so much easier. It was so easy to launch a website and appear on the first page of Google or Yahoo back then! Nowdays you will have to pay for advertising. Google Shopping is brilliant though. Do you sell items that have a barcode, brand and part number? If so, you can advertise them on there for pennies per click. You can also do targeted adverising on Facebook (for pennies) - not that I have been completely successful with that though. For small businesses, you have to think outside of the box. Be a specialist in your area. Write blog articles, contribute to forums. Do the things that big businesses can not do. Explain more about the products than any big e-commerce site could do. Film explanatory videos for your products - and upload them to YouTube. Answer the questions that people are searching for the answer to. Write lots of good content. All the best, Chris
  16. The third-party skin is one I wrote. Works perfectly on 5.2.14 - and have only made cosmetic changes for the new upgrade. Would be grateful to hear your findings, when you get a chance.
  17. Thank you for your reply. When at the addressbook, the address input fields are not already filled in. (Only the first and last name fields). When at the addressbook, the description is autofilled as 'Billing Address' but neither of the 'Billing Address' or 'Default Delivery Address' boxes are autochecked. When looking at the database, only the delivery address is saved. 'Default' has a value of 1 and 'Billing' has a value of 0. After saving a new address from the addressbook, the address is saved and the 'Default' and 'Billing' fields are correctly changed to the new address, if appropriate. I was hoping to be able to move away from hacking around with the core code with this upgrade!
  18. HI all, I have been working on upgrading my store from 5.2.14 to 6.1.14 and I am now in the testing phase. However, when I submit an order and: choose the delivery address to be the same as the invoice address enter a password and choose to register an account at the same time ... I am then taken to the address book page to add a billing address. Cubecart is not recognising that the billing address is the same and, when looking in the database, only the delivery address is saved. Does this sound like a Cubecart issue or could something be missing from my skin (something that needs to be present in new versions)? I have already searched the foundation skin for clues - but all the inputs seem the same.
  19. I built my own 'add order screen' which searches after each piece of data is entered. I find that taking a customer's telephone number first works best - as easy to mis-spell an email address. So many customers don't mention that they have ordered before - or forget they have ordered before! This approach saves us hours - it now takes an average of 2 minutes for me to take an order.
  20. Is this still happening on the new version of Cubecart? I have experienced this problem for years on my older version of Cubecart. For us: it sometimes happens when a guest customer chooses a delivery option for a quote, which is then no longer available in the dropdown once they have entered their delivery address. e.g. "UK Courier delivery" for overseas customers or "Free delivery" (orders over £75) if a customer deletes something out of their basket after selecting this option. I am about to upgrade to the latest version and assumed this had been fixed. I will file a bug report if not.
  21. I would imagine this code snippet could be adapted for this purpose: https://www.cubecart.com/extensions/code-snippets/minimum-order-quantity I am going to use it to make a minimum and maximum order quantity mod.
  22. I have just done a similar thing and the tweak you require is in the classes/seo.class.php file. Around line 47, remove the.html text from: private $_extension = '.html'; Or even better though, add the following code snippet in admin > manage hooks > code snippets. <?php $this->_extension = ''; ?> with the trigger set to: class.seo.construct
  23. Customers are receiving a blank page after payment on my v5 store so I am trying to locate the payment confirmed page too. Where is this page generated: /index.php?_g=rm&type=gateway&cmd=process&module=SagePay&cart_order_id=????
  24. DityButter: I think you will have make a small change to classes/sanitze.class.php around line 31. I have: private static $exempt = array('description', 'offline_content', 'doc_content','content_html', 'content_text', 'cat_desc', 'copyright', 'maillist_format', 'store_copyright', 'htaccess-data', 'NotificationData', 'php_code'); This offers a more helpful error message but I am now working on a much better fix. I do not want a customer to receive any error message if they have entered valid data. Error messages = abandoned baskets.
  25. Hi Toucan, thanks for your reply. I must admit, I was a little confused when posting my original question. Looking in the database, I thought customer type 2 was a registered user and type 1 was a guest! I made the change you suggested but it has not solved the problem entirely. The situation I have now: A GUEST (or ghost) user CAN place another order as a GUEST A GUEST (or ghost) CAN register during the checkout - when placing a second order - but they do not automatically get logged in so get re-directed to the log in page I have traced it so far to around line 1084 of cubecart.class.php // Log in if (isset($_POST['register']) && $_POST['register']==1 && !$GLOBALS['user']->authenticate($_POST['user']['email'], $_POST['password'], false, false, false, false)) { //chris debugging //$GLOBALS['gui']->setError('Login error - redirection prevented'); httpredir('index.php?_a=login'); } A REGISTERED user can not re-order as a GUEST so instead I give them this more helpful message: $error_messages[] = 'This email address is already in use. Please <a href='index.php?_a=login'>log in</a> or use this <a href='index.php?_a=recover'>forgot password link</a>';
×
×
  • Create New...