Resolving this @todo:

  /**
   * {@inheritdoc}
   */
  public function isVisible() {
    // @todo Check that the order contains at least one shippable entity.
    return $this->order->hasField('shipments');
  }
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

bojanz created an issue. See original summary.

iajay’s picture

Is this possible currently?

bojanz’s picture

No, hence the open issue.

rakesh.gectcr’s picture

Status: Active » Needs review

@Bojanz Need a direction,

  public function isVisible() {
    // @todo Check that the order contains at least one shippable entity.
    $order_id = $this->order->id();
    $order = Order::load($order_id)->getItems()[0]->getPurchasedEntity();
    return $this->order->hasField('shipments');
  }

Trying to check the product variation is "shippable" or not. Don't know whether it is a right direction or not. Any way struck on loading respective traits (PurchasableEntityShippable) on the product variant.:(

jsacksick’s picture

  • bojanz committed d1b8889 on 8.x-2.x authored by jsacksick
    Issue #2854495 by jsacksick, bojanz, rakesh.gectcr: Hide the...
bojanz’s picture

Status: Needs review » Fixed

Thanks, jsacksick!

shabana.navas’s picture

Status: Fixed » Needs work
FileSize
573 bytes

I believe there is a little mistake in this patch. If you look, it is returning FALSE by default, so instead of:

if (!$this->order->hasField('shipments')) {
  return TRUE;
}

it SHOULD be:

if ($this->order->hasField('shipments')) {
  return TRUE;
}

because we're doing a check for "if shipment should be visible" right. New patch has been added.

bojanz’s picture

Status: Needs work » Fixed

Looks like you misunderstood the code.
From your patch:

    * {@inheritdoc}
    */
   public function isVisible() {
-    if (!$this->order->hasField('shipments')) {
+    if ($this->order->hasField('shipments')) {
       return FALSE;
     }
 

The current code hides the pane if the order has no "shipments" field (== isn't shippable).
Your change hides the pane if the order has a shipments field (== is shippable). That doesn't make sense :)

shabana.navas’s picture

My apologies, yeah, I guess, I did misunderstand the check.

Status: Fixed » Closed (fixed)

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