I was curious if this was possible...
I am using a Ubercart patch that puts stock levels of all attribute items in the product/product listing pages (via it appends onto add_to_cart form in template.php i think).
Only thing is i have caching enabled via Boost module.
So the product/product listing pages i believe will get cached but the stock will change... is there anyway via a Conditional actions in ubercart or some Trigger/Action rule, to have it clear the Boost cache for that item if a purchase is made. Seems cool if can do this is future. Not sure if Boost or Ubercart would be responsible for doing this.

Comments

longwave’s picture

You could add a custom PHP action that runs cache_clear_all(); on the "customer completes checkout" trigger as a quick fix, but this clears all caches on your site and may cancel out much of the improvement that Boost provides.

Clearing the various caches for specific nodes will be more complicated; as far as I know it's not easy to determine which items actually need to be cleared - as well as page and node caches, there could be Views and so on to deal with.

armyofda12mnkeys’s picture

interesting... but the cache_clear_all() does sound like kills point of caching if has to clear everything... So there is there no way to clear one node's cache? The order, in uc_order_products table has a $nid. I could just set up a separate process that checks the table every hour, and looks for new orders and does something for each node like cache_just_clear($nid), but i don't know if you can clear one node's cache as a function like that doesn't seem to exist :) ... it seems like there should be a way to do this hopefully but I can't find any info on it.

armyofda12mnkeys’s picture

i used a custom PHP action to clear the BOOST cache like this: not sure if working 100% but anonymous user seems to see the update on the product/listing catalog pages that i wanted to show the updated stock on:

foreach($order->products as $product) {
  $nid = $product->nid;
  boost_expire_node($node = node_load($nid), $nid);
  error_log("Clearing out all alias's for node nid: ". $nid);

  //Get its related terms and expire catalog pages as well  
  $result = db_query("SELECT tn.tid FROM {term_node} tn INNER JOIN {term_data} td ON tn.tid=td.tid WHERE nid=%d order by nid", $nid);
  while ($row = db_fetch_array($result)) {
      $tid = $row['tid'];
      $path = "catalog/$tid";
      //error_log("Clearing out: ". $path);
      if (boost_is_cached($path)) {
        boost_cache_expire_derivative(array($path));
        if (BOOST_VERBOSE >= 5) {
          watchdog('boost', 'Rules flushed !page from static page cache.', array('!page' => $page));
        }
      }
  }

  //I have one view i list products on, so i simply clear this also... 

}

It depends on the user coming back to your site after checkout to Paypal which is payment method i using.

longwave’s picture

Category: feature » support
Status: Active » Fixed

Sounds like you fixed this, then.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.