Is it possible to display COD on a specific category?

Developer
Från India
Medlem sedan aug. 2020

Is it possible to display COD on specific catagroy and hide it on othe catagories.

tim
Founder
Från Sweden
Medlem sedan maj 2013
tim

You can conditionally show a shipping module during checkout if an item is present in one the given categories like this.

  foreach ($items as $item) {
 
  // Get product category ids
    $categories = array_keys(reference::product($item['product_id'])->categories);

  // Check if category ids are any of the following 1, 2, 3
    if (array_intersect($categories, [1, 2, 3])) {
      $show_this_module = true;
      break;
    }
  }

// Halt if module should not be shown
  if (empty($show_this_module)) return;

// Continue module here
  ...
Den här tråden har stängts på grund av lång inaktivitet. Det går inte att posta inlägg till den.
Denna webbplats använder inga kakor och ingen spårningsteknik från tredje part . Vi tror att vi kan göra det bättre än andra och tänker verkligen på din integritet.