Posted by ck9 on June 28, 2009 at 3:50pm
Jump to:
| Project: | Ubercart Userpoints |
| Version: | 6.x-2.x-dev |
| Component: | Miscellaneous |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Issue Summary
I have a range of products but wish to allow Credits as payment for only one of them. Is this possible?
Comments
#1
everything is possible :)
but not out of the box :(
what i would do to achieve this:
first you need to make sure you will not get mixed carts. if ppl put in allowed and not allowed products for your desired payment you will be in trouble at the check out. you can use hook_add_to_cart. check whats already in the cart and the disallow or allow putting the product into the cart.
now all you need to do is another hook when the payment options will be displayed. again, check whats in the cart and display only the payment option that you want. the hook you need is hook_form_alter.
you find details to the hooks at http://api.ubercart.org
#2
as i just did almost the same, here a little more help.
check if a product with a certain nodeID is already in the cart:
function nid_is_in_cart($nid){$items = uc_cart_get_contents();
foreach($items as $item) {
if(in_array($nid,get_object_vars($item))) {
return TRUE;
}else{
return FALSE;
}
}
}
hook_add_to_cart:
in my cases there are two nodes in the shop that should not be in the cart at the same time. node 1 and 9. you can check for more options if you load the node object and check for anything in the node array.
function customize_add_to_cart($nid, $qty, $data) {if (($nid == 1 && nid_is_in_cart(9))||($nid == 9 && nid_is_in_cart(1))) {
$result[] = array(
'success' => FALSE,
'message' => t('whatever you want to write here'),
);
}
return $result;
}
#3
I would like to request for this feature as well. A feature flag can be added into each product that says "allow to buy this item using userpoints". This way I could control which item can user userpoints and which cannot. Also, the above solution on checking to make sure no mixed of such products in the checkout cart.
#4
If it would be possible to select the product types (content types) that could be bought using userpoints it would be awesome.
#5
Would also be interested in this.
#6
I'm implementing something similar right now.
You can achieve this by using the ubercart conidtional payment module (http://drupal.org/project/uc_conditional_payment) in conjunction with bara.munchies cart solution. The conditional payments module allows you to specify under what conditions to use userpoints vs other payment methods, so you can specify only certain product to use certain payment methods. Just make sure to implement something similar to bara.munchies solution to prevent the mixed cart issues he mentioned.