8 – How do you flag stores when they are updated with a specific input method?

I installed the following module on my site :


I have created an “Input Modes” in “Display Modes” for the store type with the machine name commerce_store.shipping_methods


I created a custom module to automatically flag stores that are updating.

I want stores to be flagged only when updating with commerce_store.shipping_methods input mode.

How to do this ?

function admin_task_notify_commerce_store_update(Store $commerce_store) {
  if ($commerce_store->bundle() == 'ephemere' || $commerce_store->bundle() == 'personnel' || $commerce_store->bundle() == 'professionnel') {
    $flag_id = 'moderate_store';
    $flag_service = Drupal::service('flag');
    $flag = $flag_service->getFlagById($flag_id);
    $user_admin = DrupaluserEntityUser::load(1);
    $flag_status = $flag_service->getFlagging($flag, $commerce_store, $user_admin);
    if (!$flag_status) {
      $flag_service->flag($flag, $commerce_store, $user_admin);