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

Do not require address for invoice and prevent sending email without attachment #971

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
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 @@ -3,7 +3,7 @@
jQuery( document ).ready( function( $ ) {
function toggleInvoiceDetailsForm( showForm ) {
const $camptixInvoiceDetailsForm = $( '.camptix-invoice-details' );
const $camptixInvoiceDetailsFormFields = $camptixInvoiceDetailsForm.find( 'input,textarea,select' );
const $camptixInvoiceDetailsFormFields = $camptixInvoiceDetailsForm.find( 'input,select' );

if ( showForm ) {
$camptixInvoiceDetailsForm.show();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,12 @@ public static function send_invoice( $invoice_id ) {
if ( empty( $invoice_metas['email'] ) && is_email( $invoice_metas['email'] ) ) {
return false;
}//end if

$invoice_pdf = ctx_get_invoice( $invoice_id );
if ( empty( $invoice_pdf ) ) {
return false;
}

$attachments = array( $invoice_pdf );
$opt = get_option( 'camptix_options' );

Expand All @@ -348,6 +353,7 @@ public static function send_invoice( $invoice_id ) {
'Content-type: text/html; charset=UTF-8',
)
);

$message = array(
__( 'Hello,', 'wordcamporg' ),
// translators: event name.
Expand All @@ -359,6 +365,7 @@ public static function send_invoice( $invoice_id ) {
// translators: event name.
sprintf( __( 'The %s team', 'wordcamporg' ), sanitize_text_field( $opt['event_name'] ) ),
);

$message = implode( PHP_EOL, $message );
$message = '<p>' . nl2br( $message ) . '</p>';
wp_mail( $invoice_metas['email'], $subject, $message, $headers, $attachments );
Expand Down Expand Up @@ -426,10 +433,6 @@ public static function is_invoice_incomplete( $invoice_id ) {
return true;
}

if ( empty( $invoice_metas['address'] ) ) {
return true;
}

if ( empty( $invoice_order['items'] ) ) {
return true;
}
Expand Down Expand Up @@ -535,7 +538,6 @@ public static function attendee_info( $attendee_info ) {

if ( empty( $_POST['invoice-email'] )
|| empty( $_POST['invoice-name'] )
|| empty( $_POST['invoice-address'] )
|| ! is_email( wp_unslash( $_POST['invoice-email'] ) ) ) {

$camptix->error_flag( 'nope' );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<tr>
<td class="tix-left">
<label for="invoice-address">
<?php echo esc_html__( 'Recipient street address', 'wordcamporg' ); ?><span class="tix-required-star">*</span>
<?php echo esc_html__( 'Recipient street address', 'wordcamporg' ); ?>
</label>
</td>
<td class="tix-right">
Expand Down