Settings::get_settings()
Get the list of settings for Tickets Commerce.
Return
(array) The list of settings for Tickets Commerce.
Source
File: src/Tickets/Commerce/Settings.php
public function get_settings() {
$gateways_manager = tribe( Manager::class );
// @todo Replace this with a better and more performant REST API based solution.
$page_args = [
'post_status' => 'publish',
'posts_per_page' => - 1,
];
$pages = get_pages( $page_args );
if ( ! empty( $pages ) ) {
$pages = wp_list_pluck( $pages, 'post_title', 'ID' );
}
// Add an initial empty selection to the start.
$pages = [ 0 => __( '-- No page set --', 'event-tickets' ) ] + $pages;
$success_shortcode = Shortcodes\Success_Shortcode::get_wp_slug();
$checkout_shortcode = Shortcodes\Checkout_Shortcode::get_wp_slug();
/** @var \Tribe__Tickets__Commerce__Currency $commerce_currency */
$commerce_currency = tribe( 'tickets.commerce.currency' );
$paypal_currency_code_options = $commerce_currency->generate_currency_code_options();
$current_user = get_user_by( 'id', get_current_user_id() );
$settings = [
'tickets-commerce-general-settings-heading' => [
'type' => 'html',
'html' => '<h3 class="tribe-dependent" data-depends="#' . Tickets_Settings::$tickets_commerce_enabled . '-input" data-condition-is-checked>' . __( 'Tickets Commerce Settings', 'event-tickets' ) . '</h3><div class="clear"></div>',
],
static::$option_sandbox => [
'type' => 'checkbox_bool',
'label' => esc_html__( 'Enable Test Mode', 'event-tickets' ),
'tooltip' => esc_html__( 'Enables Test mode for testing payments. Any payments made will be done on "sandbox" accounts.', 'event-tickets' ),
'default' => false,
'validation_type' => 'boolean',
],
static::$option_currency_code => [
'type' => 'dropdown',
'label' => esc_html__( 'Currency Code', 'event-tickets' ),
'tooltip' => esc_html__( 'The currency that will be used for Tickets Commerce transactions.', 'event-tickets' ),
'default' => 'USD',
'validation_type' => 'options',
'options' => $paypal_currency_code_options,
],
static::$option_stock_handling => [
'type' => 'radio',
'label' => esc_html__( 'Stock Handling', 'event-tickets' ),
'tooltip' => esc_html(
sprintf(
// Translators: %s: The word "ticket" in lowercase.
_x( 'When a customer purchases a %s, the payment gateway might flag the order as Pending. The order will be Complete once payment is confirmed by the payment gateway.', 'tickets fields settings paypal stock handling', 'event-tickets' ),
tribe_get_ticket_label_singular_lowercase( 'tickets_fields_settings_paypal_stock_handling' )
)
),
'default' => Pending::SLUG,
'validation_type' => 'options',
'options' => [
Pending::SLUG => sprintf(
// Translators: %1$s: The word "ticket" in lowercase. %2$s: `<strong>` opening tag. %3$s: `</strong>` closing tag.
esc_html__( 'Decrease available %1$s stock as soon as a %2$sPending%3$s order is created.', 'event-tickets' ),
tribe_get_ticket_label_singular_lowercase( 'stock_handling' ),
'<strong>',
'</strong>'
),
Completed::SLUG => sprintf(
// Translators: %1$s: The word "ticket" in lowercase. %2$s: `<strong>` opening tag. %3$s: `</strong>` closing tag.
esc_html__( 'Only decrease available %1$s stock if an order is confirmed as %2$sCompleted%3$s by the payment gateway.', 'event-tickets' ),
tribe_get_ticket_label_singular_lowercase( 'stock_handling' ),
'<strong>',
'</strong>'
),
],
'tooltip_first' => true,
],
static::$option_checkout_page => [
'type' => 'dropdown',
'label' => esc_html__( 'Checkout page', 'event-tickets' ),
'tooltip' => esc_html(
sprintf(
// Translators: %s: The [shortcode] for the success page.
__( 'This is the page where customers go to complete their purchase. Use the %s shortcode to display the checkout experience in the page content.', 'event-tickets' ),
"[$checkout_shortcode]"
)
),
'size' => 'medium',
'validation_type' => 'options',
'options' => $pages,
'required' => true,
],
static::$option_success_page => [
'type' => 'dropdown',
'label' => esc_html__( 'Success page', 'event-tickets' ),
'tooltip' => esc_html(
sprintf(
// Translators: %s: The [shortcode] for the success page.
__( 'After a successful order, users will be redirected to this page. Use the %s shortcode to display the order confirmation to the user in the page content.', 'event-tickets' ),
"[$success_shortcode]"
)
),
'size' => 'medium',
'validation_type' => 'options',
'options' => $pages,
'required' => true,
],
static::$option_confirmation_email_sender_email => [
'type' => 'email',
'label' => esc_html__( 'Confirmation email sender address', 'event-tickets' ),
'tooltip' => esc_html(
sprintf(
// Translators: %s: The word "tickets" in lowercase.
_x( 'Email address that %s customers will receive confirmation from. Leave empty to use the default WordPress site email address.', 'tickets fields settings confirmation email', 'event-tickets' ),
tribe_get_ticket_label_plural_lowercase( 'tickets_fields_settings_paypal_confirmation_email' )
)
),
'size' => 'medium',
'default' => $current_user->user_email,
'validation_type' => 'email',
'can_be_empty' => true,
],
static::$option_confirmation_email_sender_name => [
'type' => 'text',
'label' => esc_html__( 'Confirmation email sender name', 'event-tickets' ),
'tooltip' => esc_html(
sprintf(
// Translators: %s: The word "ticket" in lowercase.
_x( 'Sender name of the confirmation email sent to customers when confirming a %s purchase.', 'tickets fields settings paypal email sender', 'event-tickets' ),
tribe_get_ticket_label_singular_lowercase( 'tickets_fields_settings_paypal_email_sender' )
)
),
'size' => 'medium',
'default' => $current_user->user_nicename,
'validation_callback' => 'is_string',
'validation_type' => 'textarea',
],
static::$option_confirmation_email_subject => [
'type' => 'text',
'label' => esc_html__( 'Confirmation email subject', 'event-tickets' ),
'tooltip' => esc_html(
sprintf(
// Translators: %s: The word "ticket" in lowercase.
_x( 'Subject of the confirmation email sent to customers when confirming a %s purchase.', 'tickets fields settings paypal email subject', 'event-tickets' ),
tribe_get_ticket_label_singular_lowercase( 'tickets_fields_settings_paypal_email_subject' )
)
),
'size' => 'large',
'default' => esc_html(
sprintf(
// Translators: %s: The word "tickets" in lowercase.
_x( 'You have %s!', 'tickets fields settings paypal email subject', 'event-tickets' ),
tribe_get_ticket_label_plural_lowercase( 'tickets_fields_settings_paypal_email_subject' )
)
),
'validation_callback' => 'is_string',
'validation_type' => 'textarea',
],
];
$settings = array_merge( $gateways_manager->get_gateway_settings(), $settings );
/**
* Allow filtering the list of Tickets Commerce settings.
*
* @since 5.1.6
*
* @param array $settings The list of Tickets Commerce settings.
*/
$settings = apply_filters( 'tribe_tickets_commerce_settings', $settings );
return array_merge( tribe( Payments_Tab::class )->get_top_level_settings(), $this->apply_commerce_enabled_conditional( $settings ) );
}
Changelog
| Version | Description |
|---|---|
| 5.1.6 | Introduced. |