Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi folks,
on my website I´ve got a self-developed Module to generate card-games. When you hav finished creating a game, I´m using node_save() to save it as a product node, then I add the node to the users cart, and redirect him to cart. When I now want to checkout, the delivery information and the calculate shipping fieldset are not displayed on checkout page.
This ist the funktion that creates the new product:
function cardgenerator_order_form_submit($form, &$form_state) {
global $user;
$sku = 'UG-' . sprintf('%08d', $_POST['user_game_id']);
if (!$nid = _cardgenerator_uc_product_exists($sku)) {
$taxonomy = taxonomy_get_term_by_name('Kartenspiele');
$product = new stdClass();
$product->type = 'product';
$product->uid = $user->uid;
$product->taxonomy = $taxonomy;
$product->model = $sku;
$product->title = _get_game_title($form_state['values']['user_game_id']);
$product->sell_price = 14.95;
$product->weight_units = 'kg';
$product->length_units = 'cm';
$product->pkg_qty = 1;
$product->default_qty = 1;
$product->shippable = 1;
$product->language = 'de';
$product->comment = 2;
$product->promote = 1;
node_save($product);
$nid = $product->nid;
}
uc_cart_add_item($nid);
}
The database entry in {uc_products} seems to be right (attached file). Has anybody an idea how to solve the problem?
Greets
dops
Comment | File | Size | Author |
---|---|---|---|
drpl_uc_products.jpg | 31.46 KB | dops |
Comments
Comment #1
dops CreditAttribution: dops commentedI solved the problem. There have to be some more parameters given to the function uc_cart_add_item().
The third paramter is needed to fetch the product attributes and the value fpr shippable! The fourth parameter defines a specific cart-id. I left the at null because the items should be added to the users cart (the users cart id is taken from the session then). The fivth parameter is only for enabling or disabling the message display.
Greets
dops
Comment #2
univate CreditAttribution: univate commented