Changeset 3224609
- Timestamp:
- 01/17/2025 07:58:40 PM (15 months ago)
- Location:
- ceretax/trunk
- Files:
-
- 5 edited
-
ceretax.php (modified) (1 diff)
-
changelog.txt (modified) (1 diff)
-
inc/admin/class-cwafc-admin-action.php (modified) (1 diff)
-
inc/class-cwafc.php (modified) (25 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
ceretax/trunk/ceretax.php
r3219747 r3224609 4 4 * Plugin URI: https://wordpress.org/plugins/ceretax/ 5 5 * Description: Simplify sales tax complexity with CereTax for WooCommerce. 6 * Version: 1.3. 06 * Version: 1.3.1 7 7 * Author: CereTax, Inc. 8 8 * Author URI: https://www.ceretax.com/ -
ceretax/trunk/changelog.txt
r3219747 r3224609 15 15 * add - Trial order (0 value order) payment with shipping amount 16 16 * add - Subscription and Renewal orders with shipping and it's payment behavior 17 18 2025-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 231 231 232 232 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( 233 243 'name' => __( 'Tax Included', 'ceretax' ), 234 244 'type' => 'checkbox', -
ceretax/trunk/inc/class-cwafc.php
r3219747 r3224609 107 107 public function action__cwafc_add_custom_item_order_admin( $order_id ) { 108 108 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' ); 111 112 112 113 $total_tax_invoice = $ceretax_data->invoice->totalTaxInvoice; 113 114 114 115 115 $order = wc_get_order( $order_id ); … … 118 118 $order_remain_fees = 0; 119 119 foreach ( $order->get_fees() as $fee_id => $fee ) { 120 if ( $fee->get_name() === 'Tax') {120 if ( $fee->get_name() === $cere_tax_name ) { 121 121 $fee_amount = $fee->get_amount(); 122 122 if ( is_numeric( $order_total_fees ) && is_numeric( $fee_amount ) ) { … … 136 136 } 137 137 echo '<tr>'; 138 echo '<td class="label">' . __( 'Tax', 'ceretax') . ':</td>';138 echo '<td class="label">' . esc_html( $cere_tax_name ) . ':</td>'; 139 139 echo '<td width="1%"></td>'; 140 140 echo '<td class="total">' . wc_price( $total_tax_invoice ) . '</td>'; … … 426 426 $custom_tax_rate = WC()->session->get( 'ceretax_rate', 0 ); 427 427 if ( empty( $custom_tax_rate ) ) { 428 $cere_tax_name = get_option( CWAFC_PREFIX . '_cere_tax_name', 'Tax' ); 428 429 $tax_str = '<tr> 429 <th>' . __( 'Tax', 'ceretax') . '</th>430 <th>' . esc_html( $cere_tax_name ) . '</th> 430 431 <td data-title="Tax"> 431 432 <span class="woocommerce-Price-amount amount"><bdi><span class="woocommerce-Price-currencySymbol">' . esc_html( get_woocommerce_currency_symbol() ) . '</span>00.00</bdi></span>'; … … 536 537 // phpcs:enable WordPress.Security.NonceVerification.Missing 537 538 $custom_tax_rate = WC()->session->get( 'ceretax_rate', 0 ); 539 $cere_tax_name = get_option( CWAFC_PREFIX . '_cere_tax_name', 'Tax' ); 538 540 if ( ! empty( $custom_tax_rate ) ) { 539 541 $tax = $custom_tax_rate; 540 542 // 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, '' ); 542 544 } elseif ( is_checkout() ) { 543 545 $tax = 0; 544 WC()->cart->add_fee( __( 'Tax', 'ceretax' ), $tax, true, '' );546 WC()->cart->add_fee( $cere_tax_name, $tax, true, '' ); 545 547 } 546 548 } … … 556 558 if ( is_wc_endpoint_url( 'order-pay' ) ) { 557 559 $cere_tax_post_transactions = get_option( CWAFC_PREFIX . '_cere_tax_post_transactions' ); 560 $cere_tax_name = get_option( CWAFC_PREFIX . '_cere_tax_name', 'Tax' ); 558 561 if ( 'yes' !== $cere_tax_post_transactions ) { 559 562 return false; … … 592 595 $custom_fee_amount = $res; 593 596 $total_rows['tax_fee'] = array( 594 'label' => __( 'Tax', 'ceretax') . ':',597 'label' => esc_html( $cere_tax_name ) . ':', 595 598 'value' => wc_price( $custom_fee_amount, array( 'currency' => $order->get_currency() ) ), 596 599 ); … … 624 627 625 628 $cere_tax_post_transactions = get_option( CWAFC_PREFIX . '_cere_tax_post_transactions' ); 629 $cere_tax_name = get_option( CWAFC_PREFIX . '_cere_tax_name', 'Tax' ); 626 630 if ( 'yes' !== $cere_tax_post_transactions ) { 627 631 return false; … … 658 662 // Define the fee amount and name. 659 663 $fee_amount = $res; 660 $fee_name = __( 'Tax', 'ceretax' );664 $fee_name = $cere_tax_name; 661 665 662 666 // Check if the fee is already added to avoid duplicates. … … 807 811 808 812 $cere_tax_post_transactions = get_option( CWAFC_PREFIX . '_cere_tax_post_transactions' ); 813 $cere_tax_name = get_option( CWAFC_PREFIX . '_cere_tax_name', 'Tax' ); 809 814 if ( 'yes' !== $cere_tax_post_transactions ) { 810 815 return false; … … 841 846 842 847 foreach ( $order->get_fees() as $fee ) { 843 if ( $fee->get_name() === 'Tax') {848 if ( $fee->get_name() === $cere_tax_name ) { 844 849 $new_fee_amount = $res; 845 850 $fee->set_amount( $new_fee_amount ); … … 853 858 if ( ! $fee_exists ) { 854 859 $item_fee = new WC_Order_Item_Fee(); 855 $item_fee->set_name( 'Tax');860 $item_fee->set_name( $cere_tax_name ); 856 861 $new_fee_amount = $res; // Replace this with the actual fee amount. 857 862 $item_fee->set_amount( $new_fee_amount ); … … 874 879 public function filter__cwafc_add_tax_calulation_when_renewal_order_placed( $renewal_order ) { 875 880 $cere_tax_post_transactions = get_option( CWAFC_PREFIX . '_cere_tax_post_transactions' ); 881 $cere_tax_name = get_option( CWAFC_PREFIX . '_cere_tax_name', 'Tax' ); 876 882 if ( 'yes' !== $cere_tax_post_transactions ) { 877 883 return false; … … 906 912 907 913 foreach ( $r_order->get_fees() as $fee ) { 908 if ( $fee->get_name() === 'Tax') {914 if ( $fee->get_name() === $cere_tax_name ) { 909 915 $new_fee_amount = $res; 910 916 $fee->set_amount( $new_fee_amount ); … … 918 924 if ( ! $fee_exists ) { 919 925 $item_fee = new WC_Order_Item_Fee(); 920 $item_fee->set_name( 'Tax');926 $item_fee->set_name( $cere_tax_name ); 921 927 $new_fee_amount = $res; // Replace this with the actual fee amount. 922 928 $item_fee->set_amount( $new_fee_amount ); … … 942 948 public function action__cwafc_order_after_calculate_totals( $and_taxes, $order ) { 943 949 $cere_tax_post_transactions = get_option( CWAFC_PREFIX . '_cere_tax_post_transactions' ); 950 $cere_tax_name = get_option( CWAFC_PREFIX . '_cere_tax_name', 'Tax' ); 944 951 if ( 'yes' !== $cere_tax_post_transactions ) { 945 952 return false; … … 975 982 $fee_exists = false; 976 983 foreach ( $order->get_fees() as $fee ) { 977 if ( $fee->get_name() === 'Tax') {984 if ( $fee->get_name() === $cere_tax_name ) { 978 985 $new_fee_amount = $res; 979 986 $fee->set_amount( $new_fee_amount ); … … 987 994 if ( ! $fee_exists ) { 988 995 $item_fee = new WC_Order_Item_Fee(); 989 $item_fee->set_name( 'Tax');996 $item_fee->set_name( $cere_tax_name ); 990 997 $new_fee_amount = $res; // Replace this with the actual fee amount. 991 998 $item_fee->set_amount( $new_fee_amount ); … … 1059 1066 $order_parent_id = $order->get_parent_id(); 1060 1067 $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 } 1061 1077 1062 1078 foreach ( $order->get_items() as $item_id => $item ) { … … 1109 1125 ); 1110 1126 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 1113 1127 // Check if deposit and scheduled orders. 1114 1128 if ( ! empty( $order_parent_id ) && 'wc_deposits' === $created_via && 'scheduled-payment' === $order_status ) { … … 1122 1136 1123 1137 // 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 ) { 1125 1139 $line_items[ $item_count ]['attributes'] = array( 1126 1140 array( … … 1171 1185 } 1172 1186 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 ); 1174 1188 1175 1189 if ( ( empty( $ceretax_stau ) || 'not_found' === $ceretax_stau ) && ! empty( $body ) && ! empty( $cere_tax_api_key ) ) { … … 1208 1222 if ( isset( $data['invoice']['totalTaxInvoice'] ) ) { 1209 1223 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'] ); 1211 1225 } 1212 1226 update_post_meta( $order->get_id(), 'ceretax_data', wp_json_encode( $data ) ); … … 1247 1261 if ( isset( $data['invoice']['totalTaxInvoice'] ) ) { 1248 1262 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'] ); 1250 1264 } 1251 1265 update_post_meta( $order->get_id(), 'ceretax_data', wp_json_encode( $data ) ); … … 1398 1412 ), 1399 1413 ); 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 }1410 1414 $item_count++; 1411 1415 -
ceretax/trunk/readme.txt
r3219747 r3224609 5 5 Tested up to: 6.6.1 6 6 Requires PHP: 5.6 7 Stable tag: 1.3. 07 Stable tag: 1.3.1 8 8 License: GNU General Public License v3.0 9 9 URI: http://www.gnu.org/licenses/gpl-3.0.html … … 36 36 == Changelog == 37 37 38 = 1.3.1 = 39 * add - Tax name field 40 * add - Fix trial with subscription order tax issue 41 38 42 = 1.3.0 = 39 43 * add - Partial payment behavior for delivery fee
Note: See TracChangeset
for help on using the changeset viewer.