Skip to content

Instantly share code, notes, and snippets.

@webaware
Created June 8, 2012 00:05
Show Gist options
  • Select an option

  • Save webaware/2892517 to your computer and use it in GitHub Desktop.

Select an option

Save webaware/2892517 to your computer and use it in GitHub Desktop.
When wp-e-commerce products are shown in an iframe, this will hopefully update the cart widget in the parent page
// example of JavaScript for somewhere on the page
<script>
function myReloadCart() {
form_values = "ajax=true&my_plugin_no_force_load=1"
jQuery.post( 'index.php?wpsc_ajax_action=get_cart', form_values, function(returned_data) {
eval(returned_data);
});
}
</script>
<?php
// example of hook code for wpsc_alternate_cart_html action hook
function theme_cart_update() {
$my_plugin_no_force_load = isset($_POST['my_plugin_no_force_load']) ? $_POST['my_plugin_no_force_load'] : 0;
if ($my_plugin_no_force_load == 0)
echo "if (window.parent) window.parent.myReloadCart();\n";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment