Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Camptix Invoices: Avoid a PHP Notice if not yet setup. #1396

Open
wants to merge 2 commits into
base: production
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,16 @@ function register_tix_invoice() {
);
}

/**
* Define the default values for options.
*/
function ctx_default_options( $options ) {
$options['invoice-vat-number'] = '';

return $options;
}
add_filter( 'camptix_default_options', 'ctx_default_options' );

/**
* Register invoice CPT custom update messages.
*/
Expand Down Expand Up @@ -254,11 +264,12 @@ function ctx_register_invoice_metabox( $post ) {
* @param object $args The args.
*/
function ctx_invoice_metabox_editable( $args ) {
global $camptix;

$order = get_post_meta( $args->ID, 'original_order', true );
$metas = get_post_meta( $args->ID, 'invoice_metas', true );
$opt = get_option( 'camptix_options' );
$invoice_vat_number = $opt['invoice-vat-number'];
$opt = $camptix->get_options();
$invoice_vat_number = $opt['invoice-vat-number'] ?? '';

if ( ! is_array( $order ) ) {
$order = array();
Expand All @@ -282,12 +293,13 @@ function ctx_invoice_metabox_editable( $args ) {
* @param object $args The args.
*/
function ctx_invoice_metabox_sent( $args ) {
global $camptix;

$order = get_post_meta( $args->ID, 'original_order', true );
$metas = get_post_meta( $args->ID, 'invoice_metas', true );
$opt = get_option( 'camptix_options' );
$invoice_vat_number = $opt['invoice-vat-number'];
$txn_id = isset( $metas['transaction_id'] ) ? $metas['transaction_id'] : '';
$opt = $camptix->get_options();
$invoice_vat_number = $opt['invoice-vat-number'] ?? '';
$txn_id = $metas['transaction_id'] ?? '';

include CTX_INV_DIR . '/includes/views/sent-invoice-metabox.php';
}
Expand Down
Loading