Plugin Directory

Changeset 3224609


Ignore:
Timestamp:
01/17/2025 07:58:40 PM (15 months ago)
Author:
ceretax
Message:

Woo plugin release v1.3.1

2025-01-15 - version 1.3.1

  • add - Tax name field
  • add - Fix trial with subscription order tax issue
Location:
ceretax/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • ceretax/trunk/ceretax.php

    r3219747 r3224609  
    44 * Plugin URI: https://wordpress.org/plugins/ceretax/
    55 * Description: Simplify sales tax complexity with CereTax for WooCommerce.
    6  * Version: 1.3.0
     6 * Version: 1.3.1
    77 * Author: CereTax, Inc.
    88 * Author URI: https://www.ceretax.com/
  • ceretax/trunk/changelog.txt

    r3219747 r3224609  
    1515 * add - Trial order (0 value order) payment with shipping amount
    1616 * add - Subscription and Renewal orders with shipping and it's payment behavior
     17
     182025-01-15 - version 1.3.1
     19 * add - Tax name field
     20 * add - Fix trial with subscription order tax issue
  • ceretax/trunk/inc/admin/class-cwafc-admin-action.php

    r3219747 r3224609  
    231231
    232232                array(
     233                    'name'     => __( 'Tax Name', 'ceretax' ),
     234                    'type'     => 'text',
     235                    'desc'     => __( 'Enter the Tax Name. If you are using a multilingual plugin do not make any changes here.', 'ceretax' ),
     236                    'id'       => CWAFC_PREFIX . '_cere_tax_name',
     237                    'desc_tip' => true,
     238                    'autoload' => false,
     239                    'default'  => 'Tax',
     240                ),
     241
     242                array(
    233243                    'name'    => __( 'Tax Included', 'ceretax' ),
    234244                    'type'    => 'checkbox',
  • ceretax/trunk/inc/class-cwafc.php

    r3219747 r3224609  
    107107        public function action__cwafc_add_custom_item_order_admin( $order_id ) {
    108108
    109             $ceretax_data = get_post_meta( $order_id, 'ceretax_data', true );
    110             $ceretax_data = json_decode( $ceretax_data );
     109            $ceretax_data  = get_post_meta( $order_id, 'ceretax_data', true );
     110            $ceretax_data  = json_decode( $ceretax_data );
     111            $cere_tax_name = get_option( CWAFC_PREFIX . '_cere_tax_name', 'Tax' );
    111112
    112113            $total_tax_invoice = $ceretax_data->invoice->totalTaxInvoice;
    113 
    114114
    115115            $order      = wc_get_order( $order_id );
     
    118118            $order_remain_fees = 0;
    119119            foreach ( $order->get_fees() as $fee_id => $fee ) {
    120                 if ( $fee->get_name() === 'Tax' ) {
     120                if ( $fee->get_name() === $cere_tax_name ) {
    121121                    $fee_amount = $fee->get_amount();
    122122                    if ( is_numeric( $order_total_fees ) && is_numeric( $fee_amount ) ) {
     
    136136            }
    137137            echo '<tr>';
    138             echo '<td class="label">' . __( 'Tax', 'ceretax' ) . ':</td>';
     138            echo '<td class="label">' . esc_html( $cere_tax_name ) . ':</td>';
    139139            echo '<td width="1%"></td>';
    140140            echo '<td class="total">' . wc_price( $total_tax_invoice ) . '</td>';
     
    426426            $custom_tax_rate = WC()->session->get( 'ceretax_rate', 0 );
    427427            if ( empty( $custom_tax_rate ) ) {
     428                $cere_tax_name = get_option( CWAFC_PREFIX . '_cere_tax_name', 'Tax' );
    428429                $tax_str = '<tr>
    429                     <th>' . __( 'Tax', 'ceretax' ) . '</th>
     430                    <th>' . esc_html( $cere_tax_name ) . '</th>
    430431                    <td data-title="Tax">
    431432                        <span class="woocommerce-Price-amount amount"><bdi><span class="woocommerce-Price-currencySymbol">' . esc_html( get_woocommerce_currency_symbol() ) . '</span>00.00</bdi></span>';
     
    536537            // phpcs:enable WordPress.Security.NonceVerification.Missing
    537538            $custom_tax_rate = WC()->session->get( 'ceretax_rate', 0 );
     539            $cere_tax_name   = get_option( CWAFC_PREFIX . '_cere_tax_name', 'Tax' );
    538540            if ( ! empty( $custom_tax_rate ) ) {
    539541                $tax = $custom_tax_rate;
    540542                // Ensure the fee is added even if the tax is 0.00.
    541                 WC()->cart->add_fee( __( 'Tax', 'ceretax' ), $tax, true, '' );
     543                WC()->cart->add_fee( $cere_tax_name, $tax, true, '' );
    542544            } elseif ( is_checkout() ) {
    543545                $tax = 0;
    544                 WC()->cart->add_fee( __( 'Tax', 'ceretax' ), $tax, true, '' );
     546                WC()->cart->add_fee( $cere_tax_name, $tax, true, '' );
    545547            }
    546548        }
     
    556558            if ( is_wc_endpoint_url( 'order-pay' ) ) {
    557559                $cere_tax_post_transactions = get_option( CWAFC_PREFIX . '_cere_tax_post_transactions' );
     560                $cere_tax_name              = get_option( CWAFC_PREFIX . '_cere_tax_name', 'Tax' );
    558561                if ( 'yes' !== $cere_tax_post_transactions ) {
    559562                    return false;
     
    592595                $custom_fee_amount                  = $res;
    593596                $total_rows['tax_fee']              = array(
    594                     'label' => __( 'Tax', 'ceretax' ) . ':',
     597                    'label' => esc_html( $cere_tax_name ) . ':',
    595598                    'value' => wc_price( $custom_fee_amount, array( 'currency' => $order->get_currency() ) ),
    596599                );
     
    624627
    625628                $cere_tax_post_transactions = get_option( CWAFC_PREFIX . '_cere_tax_post_transactions' );
     629                $cere_tax_name              = get_option( CWAFC_PREFIX . '_cere_tax_name', 'Tax' );
    626630                if ( 'yes' !== $cere_tax_post_transactions ) {
    627631                    return false;
     
    658662                // Define the fee amount and name.
    659663                $fee_amount = $res;
    660                 $fee_name   = __( 'Tax', 'ceretax' );
     664                $fee_name   = $cere_tax_name;
    661665
    662666                // Check if the fee is already added to avoid duplicates.
     
    807811
    808812            $cere_tax_post_transactions = get_option( CWAFC_PREFIX . '_cere_tax_post_transactions' );
     813            $cere_tax_name              = get_option( CWAFC_PREFIX . '_cere_tax_name', 'Tax' );
    809814            if ( 'yes' !== $cere_tax_post_transactions ) {
    810815                return false;
     
    841846
    842847                foreach ( $order->get_fees() as $fee ) {
    843                     if ( $fee->get_name() === 'Tax' ) {
     848                    if ( $fee->get_name() === $cere_tax_name ) {
    844849                        $new_fee_amount = $res;
    845850                        $fee->set_amount( $new_fee_amount );
     
    853858                if ( ! $fee_exists ) {
    854859                    $item_fee = new WC_Order_Item_Fee();
    855                     $item_fee->set_name( 'Tax' );
     860                    $item_fee->set_name( $cere_tax_name );
    856861                    $new_fee_amount = $res; // Replace this with the actual fee amount.
    857862                    $item_fee->set_amount( $new_fee_amount );
     
    874879        public function filter__cwafc_add_tax_calulation_when_renewal_order_placed( $renewal_order ) {
    875880            $cere_tax_post_transactions = get_option( CWAFC_PREFIX . '_cere_tax_post_transactions' );
     881            $cere_tax_name              = get_option( CWAFC_PREFIX . '_cere_tax_name', 'Tax' );
    876882            if ( 'yes' !== $cere_tax_post_transactions ) {
    877883                return false;
     
    906912
    907913                foreach ( $r_order->get_fees() as $fee ) {
    908                     if ( $fee->get_name() === 'Tax' ) {
     914                    if ( $fee->get_name() === $cere_tax_name ) {
    909915                        $new_fee_amount = $res;
    910916                        $fee->set_amount( $new_fee_amount );
     
    918924                if ( ! $fee_exists ) {
    919925                    $item_fee = new WC_Order_Item_Fee();
    920                     $item_fee->set_name( 'Tax' );
     926                    $item_fee->set_name( $cere_tax_name );
    921927                    $new_fee_amount = $res; // Replace this with the actual fee amount.
    922928                    $item_fee->set_amount( $new_fee_amount );
     
    942948        public function action__cwafc_order_after_calculate_totals( $and_taxes, $order ) {
    943949            $cere_tax_post_transactions = get_option( CWAFC_PREFIX . '_cere_tax_post_transactions' );
     950            $cere_tax_name              = get_option( CWAFC_PREFIX . '_cere_tax_name', 'Tax' );
    944951            if ( 'yes' !== $cere_tax_post_transactions ) {
    945952                return false;
     
    975982                $fee_exists = false;
    976983                foreach ( $order->get_fees() as $fee ) {
    977                     if ( $fee->get_name() === 'Tax' ) {
     984                    if ( $fee->get_name() === $cere_tax_name ) {
    978985                        $new_fee_amount = $res;
    979986                        $fee->set_amount( $new_fee_amount );
     
    987994                if ( ! $fee_exists ) {
    988995                    $item_fee = new WC_Order_Item_Fee();
    989                     $item_fee->set_name( 'Tax' );
     996                    $item_fee->set_name( $cere_tax_name );
    990997                    $new_fee_amount = $res; // Replace this with the actual fee amount.
    991998                    $item_fee->set_amount( $new_fee_amount );
     
    10591066            $order_parent_id = $order->get_parent_id();
    10601067            $order_type      = $order->get_type();
     1068
     1069            $total_renewal_orders = 0;
     1070            $order_subscriptions  = ( function_exists( 'wcs_get_subscriptions_for_order' ) ) ? wcs_get_subscriptions_for_order( $order->get_id(), array( 'order_type' => 'any' ) ) : array();
     1071            if ( ! empty( $order_subscriptions ) ) {
     1072                foreach ( $order_subscriptions as $subscription_id => $subscription ) {
     1073                    $renewal_orders       = ( class_exists( 'WC_Subscriptions' ) && is_object( $subscription ) && method_exists( $subscription, 'get_related_orders' ) ) ? $subscription->get_related_orders( 'all', 'renewal' ) : array();
     1074                    $total_renewal_orders = count( $renewal_orders );
     1075                }
     1076            }
    10611077
    10621078            foreach ( $order->get_items() as $item_id => $item ) {
     
    11091125                );
    11101126
    1111                 $this->cwafc_wc_add_custom_logs( array( 'order_id' => $order->get_id(), '$order_parent_id' => $order_parent_id, 'order_type' => $order_type, 'order_item_trial_length' => $order_item_trial_length, 'created_via' => $created_via, 'order_status' => $order_status ), 'ceretax-api-TEST' );
    1112 
    11131127                // Check if deposit and scheduled orders.
    11141128                if ( ! empty( $order_parent_id ) && 'wc_deposits' === $created_via && 'scheduled-payment' === $order_status ) {
     
    11221136
    11231137                // Check if subscription trial main order.
    1124                 if ( empty( $order_parent_id ) && 'subscription' !== $created_via && ! empty( $order_item_trial_length ) ) {
     1138                if ( 'subscription' === $created_via && ! empty( $order_item_trial_length ) && 1 == $total_renewal_orders ) {
    11251139                    $line_items[ $item_count ]['attributes'] = array(
    11261140                        array(
     
    11711185            }
    11721186
    1173             $ceretax_stau = get_post_meta( $order->get_id(), 'ceretax_stau', true );
     1187            $ceretax_stau = get_post_meta( $order->get_id(), 'ceretax_stau_' . $order->get_id(), true );
    11741188
    11751189            if ( ( empty( $ceretax_stau ) || 'not_found' === $ceretax_stau ) && ! empty( $body ) && ! empty( $cere_tax_api_key ) ) {
     
    12081222                if ( isset( $data['invoice']['totalTaxInvoice'] ) ) {
    12091223                    if ( ! empty( $data['systemTraceAuditNumber'] ) ) {
    1210                         update_post_meta( $order->get_id(), 'ceretax_stau', $data['systemTraceAuditNumber'] );
     1224                        update_post_meta( $order->get_id(), 'ceretax_stau_' . $order->get_id(), $data['systemTraceAuditNumber'] );
    12111225                    }
    12121226                    update_post_meta( $order->get_id(), 'ceretax_data', wp_json_encode( $data ) );
     
    12471261                if ( isset( $data['invoice']['totalTaxInvoice'] ) ) {
    12481262                    if ( ! empty( $data['systemTraceAuditNumber'] ) ) {
    1249                         update_post_meta( $order->get_id(), 'ceretax_stau', $data['systemTraceAuditNumber'] );
     1263                        update_post_meta( $order->get_id(), 'ceretax_stau_' . $order->get_id(), $data['systemTraceAuditNumber'] );
    12501264                    }
    12511265                    update_post_meta( $order->get_id(), 'ceretax_data', wp_json_encode( $data ) );
     
    13981412                        ),
    13991413                    );
    1400 
    1401                     // Check if subscription trial main order.
    1402                     if ( ! empty( $cart_item_trial_length ) ) {
    1403                         $cart_items[ $item_count ]['attributes'] = array(
    1404                             array(
    1405                                 'key'   => 'noDeliveryFee',
    1406                                 'value' => 'Y',
    1407                             ),
    1408                         );
    1409                     }
    14101414                    $item_count++;
    14111415
  • ceretax/trunk/readme.txt

    r3219747 r3224609  
    55Tested up to: 6.6.1
    66Requires PHP: 5.6
    7 Stable tag: 1.3.0
     7Stable tag: 1.3.1
    88License: GNU General Public License v3.0
    99URI: http://www.gnu.org/licenses/gpl-3.0.html
     
    3636== Changelog ==
    3737
     38= 1.3.1 =
     39* add - Tax name field
     40* add - Fix trial with subscription order tax issue
     41
    3842= 1.3.0 =
    3943* add - Partial payment behavior for delivery fee
Note: See TracChangeset for help on using the changeset viewer.