Thread Starter
DDT
(@ddt)
how do i get the product id of a product in shopping cart? This would help
How are your javascript and css skills? It would be pretty easy with the current version of wp-e-commerce.
This is how I would do it:
Write a quick little AJAX function that checks to see if the product is in the cart.
Add a little javascript that calls the AJAX function and gets the result.
Select the button class you want to enable or disable.
Set the enable or disable button using the selector from above.
Thread Starter
DDT
(@ddt)
hi jeff, thanks for thinking along.
Your ajax approach sounds good, could you give me start for the ajax part?
But as with the approach i am trying to use at this moment, do you know how to get the product id’s in the cart?
Now i am using the wpsc_cart_item_name
while(wpsc_have_cart_items()): wpsc_the_cart_item();
if( wpsc_cart_item_name() == "tickets 2014"){
echo "test tickets jquery to enabled other buttons";
}
endwhile;
but if i put this code in a function in my theme/functions.php i can’t get wpsc_have_cart_items() to work. Am i missing a global wpsc variable or something? (already tried global $wpsc).
thanks in advance,
Thread Starter
DDT
(@ddt)
hi jeff,
I am testing with
<?php
function disable_btns() {
global $wpsc;
echo "Test trigger";
while (wpsc_have_cart_items()): wpsc_the_cart_item();
if (wpsc_cart_item_name() == "tickets 2014") {
echo "test tickets jquery to enabled other buttons";
ob_start();
?>
<script>
jQuery(document).ready(function($) {
$('input[type="submit"]').removeAttr('disabled');
});
</script>
<?php
}
endwhile;
return ob_get_contents();
}
add_action('wp_footer', 'disable_btns');
but the hook isn’t right. Which hook should i use?
what’s showing up in your page source?
Thread Starter
DDT
(@ddt)
FYI and for others, i am using the following “workable” code
<?php while (wpsc_have_cart_items()): wpsc_the_cart_item();
if (wpsc_cart_item_name() == "Tickets 2014") {
echo "tesst Tickets 2014";
}
$js ='
<script>
jQuery(document).ready(function($) {
//alert("Just do it");
$(\'input:submit\').removeAttr("disabled");
});
</script>';
echo $js;
?>
regards