So I have a custom block module that displays three links, which then when clicked, reload the page and redirect to checkout based on a GET variable.
function innovista_donate_contents() {
if(isset($_GET['d'])){
switch ($_GET['d']) {
case 1:
$product_id='6';
break;
case 2:
$product_id='8';
break;
}
commerce_cart_product_add_by_id($product_id, $quantity = 1, $combine = TRUE);
drupal_goto($path = 'checkout', $options = NULL, $http_response_code = 302);
}
else {
return '<div class="col8wrap donate">
<a class="dhover" href="?d=1">Link 1</a>
<a class="dhover" href="?d=2">Link 2</a></div>';
}
}
The issue is that if you are not logged in then often the top half of this function that uses the GET var doesn't work. I thought it might be a cache issue so cleared the cache but this hasn't resolved the issue. Any idea what is going on here?
echo "<pre>".print_r($line_item)."</pre>";
inside the code and post back the output.exit()
after echo just to check the value of$line_item
.