Skip to content

Commit

Permalink
Show small business additional VAT notice within checkout block if ac…
Browse files Browse the repository at this point in the history
…tivated via filter.
  • Loading branch information
dennisnissle committed Jul 22, 2024
1 parent 3b4bfa9 commit 87ffee6
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 4 deletions.
10 changes: 10 additions & 0 deletions assets/css/admin.scss
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,16 @@ a.page-title-action {
background: #0073aa;
}

&.invalid {
border-color: #d63638;
color: #d63638;

&:hover {
border-color: #b30e10;
color: #b30e10;
}
}

&:hover {
.wc-gzd-pro:not(.wc-gzd-pro-outlined) {
background: #0a4b78;
Expand Down
17 changes: 15 additions & 2 deletions includes/admin/settings/views/html-admin-settings-tabs.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,21 @@

<?php if ( ! WC_germanized()->is_pro() ) : ?>
<a class="page-title-action" href="https://vendidero.de/woocommerce-germanized" target="_blank"><?php echo sprintf( esc_html__( 'Upgrade to %s', 'woocommerce-germanized' ), '<span class="wc-gzd-pro">pro</span>' ); ?></a>
<?php elseif ( function_exists( 'VD' ) ) : ?>
<a class="page-title-action" href="<?php echo esc_url( admin_url( 'index.php?page=vendidero' ) ); ?>"><?php esc_html_e( 'Manage license', 'woocommerce-germanized' ); ?></a>
<?php
elseif ( function_exists( 'VD' ) ) :
$license_is_valid = true;
$license_has_expired = false;

if ( function_exists( 'WC_Germanized_Pro' ) ) {
$product = is_callable( array( WC_germanized_pro(), 'get_vd_product' ) ) ? WC_germanized_pro()->get_vd_product() : null;

if ( $product ) {
$license_is_valid = $product->is_registered() && ! $product->has_expired();
$license_has_expired = $product->has_expired();
}
}
?>
<a class="page-title-action <?php echo esc_attr( ! $license_is_valid ? 'license-invalid invalid' : '' ); ?>" href="<?php echo esc_url( admin_url( 'index.php?page=vendidero' ) ); ?>"><?php echo esc_html( ( $license_has_expired ? esc_html__( 'Check your license', 'woocommerce-germanized' ) : ( $license_is_valid ? esc_html__( 'Manage license', 'woocommerce-germanized' ) : esc_html__( 'Register your license', 'woocommerce-germanized' ) ) ) ); ?></a>
<?php endif; ?>

<a class="page-title-action" href="<?php echo esc_url( add_query_arg( array( 'tutorial' => 'yes' ) ) ); ?>"><?php esc_html_e( 'Start tutorial', 'woocommerce-germanized' ); ?></a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,6 @@ public function print_debit_fields( $order ) {
* @param WC_Order $order
*/
public function save_debit_fields( $order ) {

// Check the nonce
if ( empty( $_POST['woocommerce_meta_nonce'] ) || ! wp_verify_nonce( wp_unslash( $_POST['woocommerce_meta_nonce'] ), 'woocommerce_save_data' ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
return;
Expand Down Expand Up @@ -316,7 +315,6 @@ public function save_debit_fields( $order ) {
* @return mixed
*/
public function order_actions( $actions, $order ) {

if ( ! wc_gzd_order_is_anonymized( $order ) && $order->get_payment_method() === $this->id ) {
$actions['download-sepa'] = array(
'url' => esc_url_raw(
Expand Down
7 changes: 7 additions & 0 deletions src/Blocks/Integrations/Checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ public function initialize() {

if ( ! empty( $bg_color ) ) {
$custom_css = '.wc-gzd-checkout .wp-block-woocommerce-checkout-order-summary-cart-items-block {padding: 0 !important;} .wc-gzd-checkout .wc-block-components-order-summary { background-color: ' . esc_attr( $bg_color ) . '; padding: 16px; }';

if ( wc_gzd_is_small_business() && apply_filters( 'woocommerce_gzd_small_business_show_total_vat_notice', false ) ) {
$translated = __( 'incl. VAT', 'woocommerce-germanized' );
$custom_css .= '.wc-block-components-totals-footer-item .wc-block-components-totals-item__label::after { content: " (' . esc_html( $translated ) . ')"; font-size: .6em; font-weight: normal; }';
}

wp_add_inline_style( 'wc-gzd-blocks-checkout-frontend', $custom_css );
}

Expand Down Expand Up @@ -112,6 +118,7 @@ public function get_script_data() {
$this->assets->register_data( 'buyNowButtonText', get_option( 'woocommerce_gzd_order_submit_btn_text', __( 'Buy Now', 'woocommerce-germanized' ) ) );
$this->assets->register_data( 'isSmallBusiness', wc_gzd_is_small_business() );
$this->assets->register_data( 'smallBusinessNotice', wc_get_template_html( 'global/small-business-info.php' ) );
$this->assets->register_data( 'showSmallBusinessVatNotice', apply_filters( 'woocommerce_gzd_small_business_show_total_vat_notice', false ) );

return array();
}
Expand Down

0 comments on commit 87ffee6

Please sign in to comment.