How to get current stock level?

Created on 16 February 2021, almost 4 years ago
Updated 19 January 2024, 10 months ago

I'm using hook_form_alter to set the stock_level default value by current_level, but it seems like i can't get the current_stock_level value.

function custom_module_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {

if(isset($form) && $form['#form_id'] == 'commerce_product_default_edit_form') {

// dpm($form['variations']['widget']['entity']['field_stock_level']['widget'][0]['current level']['#markup']);

$form['variations']['widget']['entity']['field_stock_level']['widget'][0]['stock_level']['#default_value'] = @stock_level should be here;
}
}

I want to get the @stock_level under #arguments to set the stock_level default value

💬 Support request
Status

Fixed

Component

Code

Created by

🇵🇭Philippines localnetwork

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024