| 1 |
<?php namespace TierPricingTable\Settings\Sections\GeneralSection; |
| 2 |
|
| 3 |
use TierPricingTable\Core\ServiceContainer; |
| 4 |
use TierPricingTable\Settings\Sections\GeneralSection\Subsections\HiddenOptionsSubsection; |
| 5 |
use TierPricingTable\Settings\Sections\GeneralSection\Subsections\LayoutSubsection; |
| 6 |
use TierPricingTable\Settings\Sections\GeneralSection\Subsections\ProductPagePriceSubsection; |
| 7 |
use TierPricingTable\Settings\Sections\SectionAbstract; |
| 8 |
use TierPricingTable\Settings\Settings; |
| 9 |
|
| 10 |
class GeneralSection extends SectionAbstract { |
| 11 |
|
| 12 |
public function getSettings() { |
| 13 |
$settings = array(); |
| 14 |
|
| 15 |
foreach ( $this->getSubsections() as $subsection ) { |
| 16 |
$settings = array_merge( $settings, ( new $subsection() )->getWrappedSettings() ); |
| 17 |
} |
| 18 |
|
| 19 |
return apply_filters( 'tiered_pricing_table/settings/general_settings', $settings ); |
| 20 |
} |
| 21 |
|
| 22 |
protected function getSubsections() { |
| 23 |
return apply_filters( 'tiered_pricing_table/settings/general_subsections', array( |
| 24 |
HiddenOptionsSubsection::class, |
| 25 |
LayoutSubsection::class, |
| 26 |
ProductPagePriceSubsection::class, |
| 27 |
) ); |
| 28 |
} |
| 29 |
|
| 30 |
public static function deleteOptions() { |
| 31 |
delete_option( Settings::SETTINGS_PREFIX . 'product_page_subsection' ); |
| 32 |
delete_option( Settings::SETTINGS_PREFIX . 'display' ); |
| 33 |
delete_option( Settings::SETTINGS_PREFIX . 'display_type' ); |
| 34 |
delete_option( Settings::SETTINGS_PREFIX . 'quantity_type' ); |
| 35 |
delete_option( Settings::SETTINGS_PREFIX . 'tooltip_color' ); |
| 36 |
delete_option( Settings::SETTINGS_PREFIX . 'tooltip_size' ); |
| 37 |
delete_option( Settings::SETTINGS_PREFIX . 'tooltip_border' ); |
| 38 |
delete_option( Settings::SETTINGS_PREFIX . 'table_title' ); |
| 39 |
delete_option( Settings::SETTINGS_PREFIX . 'position_hook' ); |
| 40 |
delete_option( Settings::SETTINGS_PREFIX . 'selected_quantity_color' ); |
| 41 |
delete_option( Settings::SETTINGS_PREFIX . 'head_quantity_text' ); |
| 42 |
delete_option( Settings::SETTINGS_PREFIX . 'head_price_text' ); |
| 43 |
delete_option( Settings::SETTINGS_PREFIX . 'show_discount_column' ); |
| 44 |
delete_option( Settings::SETTINGS_PREFIX . 'head_discount_text' ); |
| 45 |
delete_option( Settings::SETTINGS_PREFIX . 'table_quantity_measurement' ); |
| 46 |
delete_option( Settings::SETTINGS_PREFIX . 'blocks_quantity_measurement' ); |
| 47 |
delete_option( Settings::SETTINGS_PREFIX . 'product_page_price_format' ); |
| 48 |
delete_option( Settings::SETTINGS_PREFIX . 'clickable_table_rows' ); |
| 49 |
delete_option( Settings::SETTINGS_PREFIX . 'product_page_subsection' ); |
| 50 |
delete_option( Settings::SETTINGS_PREFIX . 'cart_checkout_subsection' ); |
| 51 |
delete_option( Settings::SETTINGS_PREFIX . 'summarize_variations' ); |
| 52 |
delete_option( Settings::SETTINGS_PREFIX . 'show_discount_in_cart' ); |
| 53 |
delete_option( Settings::SETTINGS_PREFIX . 'cart_checkout_subsection' ); |
| 54 |
delete_option( Settings::SETTINGS_PREFIX . 'catalog_prices_subsection' ); |
| 55 |
delete_option( Settings::SETTINGS_PREFIX . 'tiered_price_at_catalog' ); |
| 56 |
delete_option( Settings::SETTINGS_PREFIX . 'tiered_price_at_catalog_for_variable' ); |
| 57 |
delete_option( Settings::SETTINGS_PREFIX . 'tiered_price_at_catalog_cache_for_variable' ); |
| 58 |
delete_option( Settings::SETTINGS_PREFIX . 'tiered_price_at_product_page' ); |
| 59 |
delete_option( Settings::SETTINGS_PREFIX . 'tiered_price_at_catalog_type' ); |
| 60 |
delete_option( Settings::SETTINGS_PREFIX . 'lowest_prefix' ); |
| 61 |
delete_option( Settings::SETTINGS_PREFIX . 'premium_options' ); |
| 62 |
delete_option( Settings::SETTINGS_PREFIX . 'summary_section' ); |
| 63 |
delete_option( Settings::SETTINGS_PREFIX . 'display_summary' ); |
| 64 |
delete_option( Settings::SETTINGS_PREFIX . 'summary_title' ); |
| 65 |
delete_option( Settings::SETTINGS_PREFIX . 'summary_type' ); |
| 66 |
delete_option( Settings::SETTINGS_PREFIX . 'summary_total_label' ); |
| 67 |
delete_option( Settings::SETTINGS_PREFIX . 'summary_each_label' ); |
| 68 |
delete_option( Settings::SETTINGS_PREFIX . 'summary_position_hook' ); |
| 69 |
|
| 70 |
delete_option( Settings::SETTINGS_PREFIX . 'options_option_text' ); |
| 71 |
delete_option( Settings::SETTINGS_PREFIX . 'options_show_default_option' ); |
| 72 |
delete_option( Settings::SETTINGS_PREFIX . 'options_default_option_text' ); |
| 73 |
delete_option( Settings::SETTINGS_PREFIX . 'options_show_original_product_price' ); |
| 74 |
delete_option( Settings::SETTINGS_PREFIX . 'options_show_total' ); |
| 75 |
|
| 76 |
delete_option( Settings::SETTINGS_PREFIX . 'show_total_price' ); |
| 77 |
delete_option( Settings::SETTINGS_PREFIX . 'update_price_on_product_page' ); |
| 78 |
delete_option( Settings::SETTINGS_PREFIX . 'show_tiered_price_as_discount' ); |
| 79 |
} |
| 80 |
|
| 81 |
public function getSlug(): string { |
| 82 |
return 'general'; |
| 83 |
} |
| 84 |
|
| 85 |
public function getName(): string { |
| 86 |
return __( 'General', 'tier-pricing-table' ); |
| 87 |
} |
| 88 |
|
| 89 |
public static function getOptionText() { |
| 90 |
$default = __( '<strong>Buy {tp_quantity} pieces and save {tp_rounded_discount}%</strong>', |
| 91 |
'tier-pricing-table' ); |
| 92 |
|
| 93 |
return ServiceContainer::getInstance()->getSettings()->get( 'options_option_text', $default ); |
| 94 |
} |
| 95 |
|
| 96 |
public static function getPlainTextTemplate() { |
| 97 |
$default = __( '<strong>Buy {tp_quantity} pieces for {tp_price} each and save {tp_rounded_discount}%</strong>', |
| 98 |
'tier-pricing-table' ); |
| 99 |
|
| 100 |
return ServiceContainer::getInstance()->getSettings()->get( 'plain_text_template', $default ); |
| 101 |
} |
| 102 |
|
| 103 |
public static function getPlainTextFirstTierTemplate() { |
| 104 |
$default = __( '<strong>Buy {tp_quantity} pieces for {tp_price}</strong>', 'tier-pricing-table' ); |
| 105 |
|
| 106 |
return ServiceContainer::getInstance()->getSettings()->get( 'plain_text_first_tier_template', $default ); |
| 107 |
} |
| 108 |
|
| 109 |
public static function isPlainTextFirstTierEnabled(): bool { |
| 110 |
return ServiceContainer::getInstance()->getSettings()->get( 'plain_text_show_first_tier', 'yes' ) === 'yes'; |
| 111 |
} |
| 112 |
|
| 113 |
public static function getDefaultOptionText() { |
| 114 |
$default = __( '<strong>Buy {tp_quantity} pieces</strong>', 'tier-pricing-table' ); |
| 115 |
|
| 116 |
return ServiceContainer::getInstance()->getSettings()->get( 'options_default_option_text', $default ); |
| 117 |
} |
| 118 |
|
| 119 |
public static function isDefaultOptionEnabled(): bool { |
| 120 |
return ServiceContainer::getInstance()->getSettings()->get( 'options_show_default_option', 'yes' ) === 'yes'; |
| 121 |
} |
| 122 |
|
| 123 |
public static function isShowOriginalProductPrice(): bool { |
| 124 |
return ServiceContainer::getInstance()->getSettings()->get( 'options_show_original_product_price', |
| 125 |
'yes' ) === 'yes'; |
| 126 |
} |
| 127 |
|
| 128 |
public static function isShowOptionTotal(): bool { |
| 129 |
return ServiceContainer::getInstance()->getSettings()->get( 'options_show_total', 'yes' ) === 'yes'; |
| 130 |
} |
| 131 |
|
| 132 |
public static function getPricingBlocksStyle(): string { |
| 133 |
return ServiceContainer::getInstance()->getSettings()->get( 'pricing_blocks_style', 'default' ); |
| 134 |
} |
| 135 |
|
| 136 |
public static function getPricingOptionsStyle(): string { |
| 137 |
return ServiceContainer::getInstance()->getSettings()->get( 'pricing_options_style', 'default' ); |
| 138 |
} |
| 139 |
|
| 140 |
public static function getPricingTableStyle(): string { |
| 141 |
return ServiceContainer::getInstance()->getSettings()->get( 'pricing_table_style', 'default' ); |
| 142 |
} |
| 143 |
} |
| 144 |
|