ID );
$isNew = 'auto-draft' === $post->post_status;
$published = 'publish' === $post->post_status;
$status = $this->status( $post, $rule );
// only a rule in force can be overridden, and only by rules in force (skipped ones never apply)
$overriding = ( $isNew || ! $published || ! $rule->canBeOverridden() )
? array()
: ( new RuleOverlaps() )->findOverriding( $rule, GlobalTieredPricingCPT::getGlobalRules( true, false ) );
$format = get_option( 'date_format' );
?>
getPriority() ? 'open' : ''; ?>>
getPriority() ) ); ?>
hasSchedule() ? 'open' : ''; ?>>
getTitle() ); ?>
getPriority() ) );
if ( $other->hasSchedule() ) {
echo ', ' . esc_html( self::scheduleSummary( $other ) );
}
?>
getEffectiveStatus() ) ) : ?>
post_status ) {
return array(
'key' => 'draft',
'label' => __( 'Not published', 'tier-pricing-table' ),
'detail' => __( 'Publish the rule to put it in force.', 'tier-pricing-table' ),
'icon' => 'dashicons-edit',
);
}
switch ( $rule->getEffectiveStatus() ) {
case 'suspended':
return array(
'key' => 'suspended',
'label' => __( 'Suspended', 'tier-pricing-table' ),
'detail' => __( 'The rule is saved but does not apply until you reactivate it.', 'tier-pricing-table' ),
'icon' => 'dashicons-controls-pause',
);
case 'expired':
return array(
'key' => 'expired',
'label' => __( 'Expired', 'tier-pricing-table' ),
/* translators: %s: date */
'detail' => sprintf( __( 'Ended %s. Clear or move the end date to use the rule again.', 'tier-pricing-table' ), wp_date( $format, $rule->getEndTimestamp() ) ),
'icon' => 'dashicons-dismiss',
);
case 'skipped':
return array(
'key' => 'skipped',
'label' => __( 'Skipped', 'tier-pricing-table' ),
'detail' => __( 'The rule changes neither prices nor quantity limits, so the storefront skips it. Set a price, tiers or a limit on the tabs on the left.', 'tier-pricing-table' ),
'icon' => 'dashicons-warning',
);
case 'scheduled':
return array(
'key' => 'scheduled',
'label' => __( 'Scheduled', 'tier-pricing-table' ),
/* translators: %s: date */
'detail' => sprintf( __( 'Starts %s.', 'tier-pricing-table' ), wp_date( $format, $rule->getStartTimestamp() ) ),
'icon' => 'dashicons-clock',
);
}
return array(
'key' => 'active',
'label' => __( 'Active', 'tier-pricing-table' ),
'detail' => $rule->getEndDate()
/* translators: %s: date */
? sprintf( __( 'Applies now, until %s.', 'tier-pricing-table' ), wp_date( $format, $rule->getEndTimestamp() ) )
: __( 'Applies now.', 'tier-pricing-table' ),
'icon' => 'dashicons-yes-alt',
);
}
/**
* "Always", "From …", "Until …" or "… to …".
*/
public static function scheduleSummary( GlobalPricingRule $rule ): string {
if ( ! $rule->hasSchedule() ) {
return __( 'Always', 'tier-pricing-table' );
}
$format = get_option( 'date_format' );
$from = $rule->getStartDate() ? wp_date( $format, $rule->getStartTimestamp() ) : null;
$to = $rule->getEndDate() ? wp_date( $format, $rule->getEndTimestamp() ) : null;
if ( $from && $to ) {
/* translators: 1: start date, 2: end date */
return sprintf( __( '%1$s to %2$s', 'tier-pricing-table' ), $from, $to );
}
if ( $from ) {
/* translators: %s: start date */
return sprintf( __( 'From %s', 'tier-pricing-table' ), $from );
}
/* translators: %s: end date */
return sprintf( __( 'Until %s', 'tier-pricing-table' ), $to );
}
}