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. I built a till system on to the back end of CubeCart - so it's doeable! I would love to make it available for others one day. I have the vision of a till system that can integrate with any e-commerce platform. And is also your accounting system too. I have done lots of the work - but its going to be the end of the year before I can do anymore work on it now.
  16. Probably what I should have said is "anything is possible if you have enough time (and desire)"! Do you know what format the live feeds are in, is it an api or is it a file that you download? I get sent .csv files from suppliers daily and then I upload them to my own admin system - which has a csv upload script in it. If you Google "csv upload script" you will get example code. You will need a new table in your database to store the uploaded data. And then you will need some more code to do whatever it is you want to do with the data. p.s. you might want to change the tile of this thread - rather than "Mr" (!) - to get more views.
  17. Hi all, I'm looking to add store collection / click & collect to my website. The store collection plugin doesn't seem to do anything other than offer the free collection option (as a shipping method). So... I think I'll need to make the following improvements: 1. When choosing "Store Collection" the delivery address get's auto-filled with my shop address. 2. A BIG message to say "you have chosen to collect your order" and "please don't collect until you have received an e-mail to say your order is ready for collection". etc. etc. 3. An estimated time/date that the order will be ready for collection 4. An option to pay in store (not sure if this is a good idea) 5. Improvements/changes to the e-mails to say "you have chose to collect from store/we will not be sending your order" etc. etc. And maybe also directions to the store (or at least a link to the directions page) 6. Improvements to the despatch e-mail - change to "your order is ready for collection" e-mail 7. A "your order has been collected" e-mail. Has anyone else done this kind of thing? Any other suggestions of things to include or tips to implement? Regards, Chris
  18. Everything is possible! I have stock feeds that I drag and drop in to my admin once a day - which updates retail prices and supplier stock levels. You would need someone to write the code for you, if you're not "techy".
  19. 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
  20. Hi all, I like to still provide access to inactive products visible, when visited directly - rather than displaying a 404 page. (Some of these products get plenty of visitors from Google as no one else lists them anymore.) Whilst the product is no longer available to buy, we do have alternative products listed on the page - and it might just be that the product has been superceeded. I don't want the inactive products to appear in category pages. The only way I can see to do this is by overwriting line 1037 in the catalogue.class (inside the getProductData function) to: $where = $this->outOfStockWhere(array('product_id' => $product_id)); Am I missing anyway of doing this without hacking the code? Regards, Chris
  21. Brilliant. Found it! Like you mentioned, it was the htaccess file in /my_own_admin/ I used this for an extra bit of security before the login page.... AuthType Basic AuthName "Password Protected Area" AuthUserFile /home/*****/public_html/******/.htpasswd Require valid-user I've removed this and I'm straight in now. Many thanks for your help.
  22. The reason I can probably access on my phone is because I had the my_own_admin/index.php in a browser window already on my phone before the upgrade so, after the upgrade, I opened it up - was redirected to my_own_admin/login.php , logged in and it all works. That proves it is there but I can't get my head around how to allow it it to be displayed in any browser. Do you think I need in a line in the htaccess file or should a correct entry in seo.class do the job?
  23. If I go to /my_own_admin/login.php it just goes straight to the Cubecart default 404 page. Same with /my_own_admin/index.php (which would have previously directed to login.php).
  24. I can access the normal (CubeCart's) admin system. However, I have an additional admin system located at a different url (e.g. {STORE_URL}/my_own_admin/login.php). Cubecart obviously doesn't recognise the url so I'm wondering where I should let it know about it - so it doesn't send me to a 404.
  25. Hello, I have finally upgraded to v6. I have my own admin system which is at a url along the lines of: {STORE_URL}/my_own_admin/login.php I get a 404 error when I try to visit it now. (I can still access it from my phone - so it is definitely there). Would anyone know if it is best to make changes in: seo.class.php (I have already added 'my_own_admin' to the ignored url sections) or the .htacess file - or both? Many thanks, Chris
×
×
  • Create New...