';
}
public function getSlug() {
return 'non-logged-in-users';
}
public function run() {
// the Wholesale tab: registration settings first, the guest options as its last group
new WholesaleSettings();
new CartRulesSettings();
add_filter( 'tiered_pricing_table/settings/wholesale_subsections', array($this, 'addSettingsSubsection') );
// the private store is part of the free plugin: the closed store checks its own switch on every
// request; catalog visibility by role is an opt-in, so the product and category screens stay
// simple by default
new ClosedStoreService();
if ( VisibilitySettings::isEnabled() ) {
new ProductVisibilityService();
if ( is_admin() ) {
new ProductVisibilityFields();
new CategoryVisibilityFields();
new ProductListColumn();
new ProductListFilter();
new CategoryListColumn();
}
}
// wholesale registration is part of the free plugin too
if ( WholesaleSettings::isEnabled() ) {
new ApplicationCPT();
new ApplicationAdmin();
new EmailsManager();
new RegistrationForm();
new LoginRedirect();
} else {
// the shortcode stays known, so a page that carries it explains itself to the store owner
add_shortcode( RegistrationForm::SHORTCODE, array($this, 'renderDisabledNote') );
}
return;
// premium: the guest options and the cart rules
add_action( 'init', function () {
$this->getContainer()->initService( NonLoggedInUsersService::class );
} );
if ( CartRulesSettings::isEnabled() ) {
new CartRulesService();
}
}
public function addSettingsSubsection( $subsections ) {
// the private store is free; the cart rules and the guest options are premium and are shown
// locked in the free version (PremiumSettingsManager)
$subsections[] = PrivateStoreSubsection::class;
$subsections[] = CartRulesSubsection::class;
$subsections[] = PaymentMethodsSubsection::class;
$subsections[] = ShippingMethodsSubsection::class;
$subsections[] = NonLoggedInUsersSubsection::class;
return $subsections;
}
public function renderDisabledNote() : string {
if ( !current_user_can( 'manage_woocommerce' ) ) {
return '';
}
$url = admin_url( 'admin.php?page=wc-settings&tab=tiered_pricing_table_settings§ion=wholesale' );
return '' . sprintf(
/* translators: %s: link to the settings */
esc_html__( 'Wholesale registration is switched off. Enable it under %s. Only shop managers see this note.', 'tier-pricing-table' ),
'' . esc_html__( 'Tiered Pricing → Wholesale', 'tier-pricing-table' ) . ''
) . '
';
}
}