I get tunnel vision from issues like this, so I decided to modify the module to allow the block to be displayed in a special URL location so that this variable number of pages' carts can be updated every 10 seconds if and only if the contents of the block displayed at the URL endpoint I created are different than those found from the opened pages. In other words, if I display my special cart block at, say, "http://website.com/?q=ajax-cart-block", I can use this to determine if any carts are different from this "centralized cart contents." If they are, I'll then use jQuery to clone the contents of this endpoint to update accordingly the carts that are opened in the browser pages / tabs. Thoughts?
I've modified dc_ajax_add_cart.module (the main module file) with the following:
Code: Select all
$items['ajax-cart-block'] = array(
'title' => '',
'description' => 'Your current cart',
'page callback' => 'dc_get_cart',
'access arguments' => array('access content'),
);
Code: Select all
function dc_get_cart() {
$block = block_load('dc_ajax_add_cart', "ajax_shopping_cart");
$output = drupal_render(_block_get_renderable_array(_block_render_blocks(array($block))));
print $output;
}The problem is that when I go to view the cart at http://website.com/?q=ajax-cart-block, I get the block as expected but the forms in the block code (the line items, that is) do not update as expected whenever I try to either remove or update one of the items. I examined the markup and one difference between the markup from this block and those found on the "normal pages" is that it's missing the "ajax-processed" class on some of the elements. Any idea why this might be? Should I just scrap this entire idea and rely on my customers being intelligent enough to check their own orders at confirmation? (Bad question, I know! Ha.)
Thanks in advance.