- πΊπΈUnited States TomTech
Automatically closed because Drupal 7 security and bugfix support has ended β as of 5 January 2025. If the issue verifiably applies β to later versions, please reopen with details and update the version.
I want to create a commerce product with a licence role field value being set in a hook_update_n.
function my_module_update_7000(&$sandbox) {
$product = commerce_product_new('product');
$product->sku = 'my_product';
$product->title = 'My product';
$product->uid = 1;
$product->commerce_price[LANGUAGE_NONE][0]['amount'] = 10000;
$product->commerce_price[LANGUAGE_NONE][0]['currency_code'] = 'EUR';
// Set 'editor' as the role that will be assigned to a user when he buys this product
$product->commerce_license_role[LANGUAGE_NONE][0] = array('value' => 4);
commerce_product_save($product);
}
The product gets created and in the ui the value is showing up correctly.
But the role is not being assigned when a user buys this product.
It isn't until I save the product via the ui that it is working.
I thought calling commerce_product_save would be sufficient to save the product correctly programmatically.
Is there something else I am overlooking?
Closed: outdated
1.3
Code
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
Automatically closed because Drupal 7 security and bugfix support has ended β as of 5 January 2025. If the issue verifiably applies β to later versions, please reopen with details and update the version.