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

CommentFileSizeAuthor
drpl_uc_products.jpg31.46 KBdops
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dops’s picture

I solved the problem. There have to be some more parameters given to the function uc_cart_add_item().

uc_cart_add_item($nid, 1, module_invoke_all('add_to_cart_data', array('nid' => $nid)), NULL, variable_get('uc_cart_add_item_msg', TRUE));

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

univate’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.