Changeset 2089141
- Timestamp:
- 05/16/2019 01:12:37 PM (7 years ago)
- Location:
- cardgate
- Files:
-
- 8 edited
- 1 copied
-
tags/3.1.13 (copied) (copied from cardgate/trunk)
-
tags/3.1.13/cardgate-clientlib-php/src/Client.php (modified) (1 diff)
-
tags/3.1.13/cardgate.php (modified) (1 diff)
-
tags/3.1.13/classes/CGP_Common_Gateway.php (modified) (9 diffs)
-
tags/3.1.13/readme.txt (modified) (1 diff)
-
trunk/cardgate-clientlib-php/src/Client.php (modified) (1 diff)
-
trunk/cardgate.php (modified) (1 diff)
-
trunk/classes/CGP_Common_Gateway.php (modified) (9 diffs)
-
trunk/readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
cardgate/tags/3.1.13/cardgate-clientlib-php/src/Client.php
r2046053 r2089141 298 298 if ( 299 299 ! is_string( $sIp_ ) 300 || FALSE === filter_var( $sIp_, FILTER_VALIDATE_IP ) // NOTE ipv6300 || FALSE === filter_var( $sIp_, FILTER_VALIDATE_IP) 301 301 ) { 302 302 throw new Exception( 'Client.Ip.Invalid', 'invalid IP address: ' . $sIp_ ); -
cardgate/tags/3.1.13/cardgate.php
r2052675 r2089141 7 7 * Text Domain: cardgate 8 8 * Domain Path: /i18n/languages 9 * Version: 3.1.1 29 * Version: 3.1.13 10 10 * Requires at least: 4.4 11 11 * Author: CardGate -
cardgate/tags/3.1.13/classes/CGP_Common_Gateway.php
r2052675 r2089141 16 16 17 17 var $bankOption; 18 19 18 var $logo; 19 var $bSeperateSalesTax; 20 20 21 21 // //////////////////////////////////////////////// … … 187 187 188 188 $oCardGate->setIp($_SERVER['REMOTE_ADDR']); 189 189 190 $oCardGate->setLanguage($sLanguage); 190 191 $oCardGate->version()->setPlatformName('Woocommerce'); … … 433 434 private function getCartItems($iOrderId) { 434 435 global $woocommerce; 436 437 $sDefaultCountry = get_option( 'woocommerce_default_country' ); 438 439 $this->bSeperateSalesTax = (stripos($sDefaultCountry,'US') === false ? false : true); 435 440 436 441 $nr = 0; … … 454 459 $iTax = round(($oItem->get_total_tax() * 100) / $iQty); 455 460 $iTotal = round($iPrice + $iTax); 456 $iTaxrate = ($iTax > 0 ? round((($oItem->get_total_tax() * 100) / $iQty) / (($oItem->get_total()) / $iQty), 1) : 0);461 $iTaxrate = $this->get_tax_rate($oProduct); 457 462 } else { 458 463 459 464 $aItem = $oItem; 460 465 $sName = $aItem['name']; 461 466 $sModel = 'product_' . $aItem['item_meta']['_product_id'][0]; 462 467 $oProduct = $oOrder->get_product_from_item($aItem); 463 $iQty = (int) $aItem['item_meta']['_qty'][0];468 $iQty = (int)$aItem['item_meta']['_qty'][0]; 464 469 $iPrice = round(($oOrder->get_item_total($aItem, false, false) * 100)); 465 470 $iTax = round(($oOrder->get_item_tax($aItem, false) * 100)); … … 489 494 foreach ($aShipping_methods as $oShipping) { 490 495 if (is_object($oShipping)) { 496 491 497 $sName = $oShipping->get_name(); 492 498 $sModel = $oShipping->get_type(); … … 494 500 $iTax = round($oShipping->get_total_tax() * 100); 495 501 $iTotal = round($iPrice + $iTax); 496 $iTaxrate = ($iTax > 0 ? round(($oShipping->get_total_tax() / $oShipping->get_total()) * 100, 1) : 0);497 502 } else { 498 503 $aShipping = $oShipping; … … 502 507 $iTax = round($oOrder->get_shipping_tax() * 100); 503 508 $iTotal = round($iPrice + $iTax); 504 $iTaxrate = ($iTax > 0 ? round(($oOrder->get_shipping_tax() / $oOrder->get_total_shipping()) * 100, 1) : 0);505 509 } 510 $iTaxrate = $this->get_shipping_tax_rate($iTotal); 511 506 512 $nr ++; 507 513 $items[$nr]['type'] = 'shipping'; … … 517 523 } 518 524 } 519 525 520 526 $fpExtraFee = (empty($woocommerce->session->extra_cart_fee) ? 0 : $woocommerce->session->extra_cart_fee); 521 527 $iExtraFee = round($fpExtraFee * 100); … … 584 590 return true; 585 591 } 592 } 593 594 595 596 public function get_tax_rate($oProduct){ 597 $sDefaultCountry = get_option( 'woocommerce_default_country' ); 598 if (stripos($sDefaultCountry,'US') === false){ 599 $oTax = new WC_Tax(); 600 $aTempRates = $oTax->get_rates( $oProduct->get_tax_class() ); 601 $aVat = array_shift( $aTempRates ); 602 if ( isset( $aVat['rate'] ) ) { 603 $dItemTaxRate = round( $aVat['rate'],2 ); 604 } else { 605 $dItemTaxRate = 0; 606 } 607 } else { 608 $dItemTaxRate = 0; 609 } 610 611 return $dItemTaxRate; 612 } 613 614 public function get_shipping_tax_rate($iTotal) { 615 616 if ( $iTotal > 0 && ! $this->bSeperateSalesTax ) { 617 $oTax = new WC_Tax(); 618 $aShippingRates = $oTax->get_shipping_tax_rates(); 619 $aVat = array_shift( $aShippingRates ); 620 if ( isset( $aVat['rate'] ) ) { 621 $dShippingTaxRate = round( $aVat['rate'], 2); 622 } else { 623 $dShippingTaxRate = 0; 624 } 625 } else { 626 $dShippingTaxRate = 0; 627 } 628 629 return $dShippingTaxRate; 586 630 } 587 631 -
cardgate/tags/3.1.13/readme.txt
r2078573 r2089141 5 5 Requires at least: 4.2 6 6 Tested up to: 5.2 7 Stable tag: 3.1.1 27 Stable tag: 3.1.13 8 8 License: GPLv3 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-3.0.html -
cardgate/trunk/cardgate-clientlib-php/src/Client.php
r2046053 r2089141 298 298 if ( 299 299 ! is_string( $sIp_ ) 300 || FALSE === filter_var( $sIp_, FILTER_VALIDATE_IP ) // NOTE ipv6300 || FALSE === filter_var( $sIp_, FILTER_VALIDATE_IP) 301 301 ) { 302 302 throw new Exception( 'Client.Ip.Invalid', 'invalid IP address: ' . $sIp_ ); -
cardgate/trunk/cardgate.php
r2052675 r2089141 7 7 * Text Domain: cardgate 8 8 * Domain Path: /i18n/languages 9 * Version: 3.1.1 29 * Version: 3.1.13 10 10 * Requires at least: 4.4 11 11 * Author: CardGate -
cardgate/trunk/classes/CGP_Common_Gateway.php
r2052675 r2089141 16 16 17 17 var $bankOption; 18 19 18 var $logo; 19 var $bSeperateSalesTax; 20 20 21 21 // //////////////////////////////////////////////// … … 187 187 188 188 $oCardGate->setIp($_SERVER['REMOTE_ADDR']); 189 189 190 $oCardGate->setLanguage($sLanguage); 190 191 $oCardGate->version()->setPlatformName('Woocommerce'); … … 433 434 private function getCartItems($iOrderId) { 434 435 global $woocommerce; 436 437 $sDefaultCountry = get_option( 'woocommerce_default_country' ); 438 439 $this->bSeperateSalesTax = (stripos($sDefaultCountry,'US') === false ? false : true); 435 440 436 441 $nr = 0; … … 454 459 $iTax = round(($oItem->get_total_tax() * 100) / $iQty); 455 460 $iTotal = round($iPrice + $iTax); 456 $iTaxrate = ($iTax > 0 ? round((($oItem->get_total_tax() * 100) / $iQty) / (($oItem->get_total()) / $iQty), 1) : 0);461 $iTaxrate = $this->get_tax_rate($oProduct); 457 462 } else { 458 463 459 464 $aItem = $oItem; 460 465 $sName = $aItem['name']; 461 466 $sModel = 'product_' . $aItem['item_meta']['_product_id'][0]; 462 467 $oProduct = $oOrder->get_product_from_item($aItem); 463 $iQty = (int) $aItem['item_meta']['_qty'][0];468 $iQty = (int)$aItem['item_meta']['_qty'][0]; 464 469 $iPrice = round(($oOrder->get_item_total($aItem, false, false) * 100)); 465 470 $iTax = round(($oOrder->get_item_tax($aItem, false) * 100)); … … 489 494 foreach ($aShipping_methods as $oShipping) { 490 495 if (is_object($oShipping)) { 496 491 497 $sName = $oShipping->get_name(); 492 498 $sModel = $oShipping->get_type(); … … 494 500 $iTax = round($oShipping->get_total_tax() * 100); 495 501 $iTotal = round($iPrice + $iTax); 496 $iTaxrate = ($iTax > 0 ? round(($oShipping->get_total_tax() / $oShipping->get_total()) * 100, 1) : 0);497 502 } else { 498 503 $aShipping = $oShipping; … … 502 507 $iTax = round($oOrder->get_shipping_tax() * 100); 503 508 $iTotal = round($iPrice + $iTax); 504 $iTaxrate = ($iTax > 0 ? round(($oOrder->get_shipping_tax() / $oOrder->get_total_shipping()) * 100, 1) : 0);505 509 } 510 $iTaxrate = $this->get_shipping_tax_rate($iTotal); 511 506 512 $nr ++; 507 513 $items[$nr]['type'] = 'shipping'; … … 517 523 } 518 524 } 519 525 520 526 $fpExtraFee = (empty($woocommerce->session->extra_cart_fee) ? 0 : $woocommerce->session->extra_cart_fee); 521 527 $iExtraFee = round($fpExtraFee * 100); … … 584 590 return true; 585 591 } 592 } 593 594 595 596 public function get_tax_rate($oProduct){ 597 $sDefaultCountry = get_option( 'woocommerce_default_country' ); 598 if (stripos($sDefaultCountry,'US') === false){ 599 $oTax = new WC_Tax(); 600 $aTempRates = $oTax->get_rates( $oProduct->get_tax_class() ); 601 $aVat = array_shift( $aTempRates ); 602 if ( isset( $aVat['rate'] ) ) { 603 $dItemTaxRate = round( $aVat['rate'],2 ); 604 } else { 605 $dItemTaxRate = 0; 606 } 607 } else { 608 $dItemTaxRate = 0; 609 } 610 611 return $dItemTaxRate; 612 } 613 614 public function get_shipping_tax_rate($iTotal) { 615 616 if ( $iTotal > 0 && ! $this->bSeperateSalesTax ) { 617 $oTax = new WC_Tax(); 618 $aShippingRates = $oTax->get_shipping_tax_rates(); 619 $aVat = array_shift( $aShippingRates ); 620 if ( isset( $aVat['rate'] ) ) { 621 $dShippingTaxRate = round( $aVat['rate'], 2); 622 } else { 623 $dShippingTaxRate = 0; 624 } 625 } else { 626 $dShippingTaxRate = 0; 627 } 628 629 return $dShippingTaxRate; 586 630 } 587 631 -
cardgate/trunk/readme.txt
r2078573 r2089141 5 5 Requires at least: 4.2 6 6 Tested up to: 5.2 7 Stable tag: 3.1.1 27 Stable tag: 3.1.13 8 8 License: GPLv3 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-3.0.html
Note: See TracChangeset
for help on using the changeset viewer.