Plugin Directory

Changeset 2781410


Ignore:
Timestamp:
09/07/2022 02:32:10 PM (4 years ago)
Author:
CardGate
Message:

instructions field

Location:
cardgate
Files:
8 edited
1 copied

Legend:

Unmodified
Added
Removed
  • cardgate/tags/3.1.22/cardgate-clientlib-php/src/Client.php

    r2588602 r2781410  
    3636         * Client version.
    3737         */
    38         const CLIENT_VERSION = "1.1.15";
     38        const CLIENT_VERSION = "1.1.17";
    3939
    4040        /**
  • cardgate/tags/3.1.22/cardgate.php

    r2588602 r2781410  
    77 * Author: CardGate
    88 * Author URI: https://www.cardgate.com
    9  * Version: 3.1.21
     9 * Version: 3.1.22
    1010 * Text Domain: cardgate
    1111 * Domain Path: /i18n/languages
    1212 * Requires at least: 4.4
    13  * WC requires at least: 2.1.0
    14  * WC tested up to: 5.6.0
     13 * WC requires at least: 3.0.0
     14 * WC tested up to: 6.8.2
    1515 * License: GPLv3 or later
    1616 */
  • cardgate/tags/3.1.22/classes/CGP_Common_Gateway.php

    r2532998 r2781410  
    2020    var $logo;
    2121    var $bSeperateSalesTax;
     22    var $instructions;
    2223
    2324    // ////////////////////////////////////////////////
     
    2728        $this->title = (isset($this->settings['title']) && !empty($this->settings['title']) ? $this->settings['title'] : $this->payment_name);
    2829        $this->description = $this->settings['description'];
     30        $this->instructions = (!empty($this->settings['instructions']) ? $this->settings['instructions'] : '');
    2931
    3032        add_filter ( 'woocommerce_gateway_icon', array($this, 'modify_icon'), 20, 2 );
    3133        add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) );
    3234        add_action( 'woocommerce_receipt_' . $this->id, array( $this, 'receiptPage' ) );
     35        add_action( 'woocommerce_thankyou_' . $this->id, array( $this, 'thankyou_page' ) );
    3336    }
    3437
     
    4447        }
    4548    }
     49
     50    /**
     51     * Output for the order received page.
     52     */
     53    public function thankyou_page() {
     54        if ( $this->instructions ) {
     55            echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) );
     56        }
     57    }
    4658
    4759    // ////////////////////////////////////////////////
     
    147159                'default'     => __( 'Pay with ', 'cardgate' ) . $this->payment_name,
    148160                'desc_tip'    => true
    149             ]
     161            ],
     162            'instructions'       => [
     163                'title'       => __( 'Instructions', 'cardgate' ),
     164                'type'        => 'textarea',
     165                'description' => __( 'Instructions that will be added to the thank you page.', 'cardgate' ),
     166                'default'     => __( '', 'cardgate' ),
     167                'desc_tip'    => true
     168            ]
    150169        ];
    151170    }
     
    180199    public function process_payment( $iOrderId ) {
    181200        global $woocommerce;
    182 
    183201        try {
    184202
     
    546564                $sModel   = $this->formatSku( $oProduct );
    547565                $iQty     = $oItem->get_quantity();
    548                 $iPrice   = round( ( $oItem->get_total() * 100 ) / $iQty );
    549                 $iTax     = round( ( $oItem->get_total_tax() * 100 ) / $iQty );
     566                $iPrice   = round( ( $oItem->get_subtotal() * 100 ) / $iQty );
     567                $iTax     = round( ( $oItem->get_subtotal_tax() * 100 ) / $iQty );
    550568                $iTotal   = round( $iPrice + $iTax );
    551569                $iTaxrate = $this->get_tax_rate( $oProduct );
     
    577595
    578596        $iShippingTotal    = 0;
    579         $iShippingVatTotal = 0;
     597        $ishippingTaxTotal = 0;
    580598
    581599        $aShipping_methods = $oOrder->get_shipping_methods();
     
    610628
    611629                $iShippingTotal    = $iPrice;
    612                 $iShippingVatTotal = $iTax;
     630                $ishippingTaxTotal = $iTax;
    613631            }
    614632        }
     
    629647        }
    630648
    631         $iTaxDifference = round( $oOrder->get_total_tax() * 100 ) - $iCartItemTaxTotal - $iShippingVatTotal;
     649        $iDiscountTotal = 0;
     650        $iDiscountTaxTotal = 0;
     651
     652        $aOrderData = $oOrder->get_data();
     653        if ( $aOrderData['discount_total'] > 0 ) {
     654            $iDiscountTaxTotal = round($aOrderData['discount_tax'] * -100);
     655            $iDiscountTotal = round($aOrderData['discount_total'] * -100);
     656            $iDiscountVat = round($aOrderData['discount_tax'] / $aOrderData['discount_total'] * 100);
     657
     658            $nr ++;
     659            $items[ $nr ]['type']       = 'discount';
     660            $items[ $nr ]['model']      = 'discount_total';
     661            $items[ $nr ]['name']       = 'Discount';
     662            $items[ $nr ]['quantity']   = 1;
     663            $items[ $nr ]['price_wt']   = $iDiscountTotal;
     664            $items[ $nr ]['vat']        = $iDiscountVat;
     665            $items[ $nr ]['vat_amount'] = $iDiscountTaxTotal;
     666        }
     667
     668        $iTaxDifference = round( $oOrder->get_total_tax() * 100 ) - $iCartItemTaxTotal - $ishippingTaxTotal - $iDiscountTaxTotal;
    632669        if ( $iTaxDifference != 0 ) {
    633670            $nr ++;
     
    641678        }
    642679
    643         $iCorrection = round( $iOrderTotal - $iCartItemTotal - $iCartItemTaxTotal - $iShippingTotal - $iShippingVatTotal - $iExtraFee - $iTaxDifference );
     680        $iCorrection = round( $iOrderTotal - $iCartItemTotal - $iCartItemTaxTotal - $iShippingTotal - $ishippingTaxTotal - $iExtraFee - $iTaxDifference - $iDiscountTotal - $iDiscountTaxTotal);
    644681
    645682        if ( $iCorrection != 0 ) {
  • cardgate/tags/3.1.22/readme.txt

    r2665824 r2781410  
    55Requires at least: 4.4
    66Tested up to: 5.9
    7 Stable tag: 3.1.21
     7Stable tag: 3.1.22
    88License: GPLv3 or later
    99License URI: https://www.gnu.org/licenses/gpl-3.0.html
     
    7575
    7676== Changelog ==
     77
     78= 3.1.22 =
     79* Added: Instructions field
     80* Added: Discount items
     81* update: Client Lib
    7782
    7883= 3.1.21 =
  • cardgate/trunk/cardgate-clientlib-php/src/Client.php

    r2588602 r2781410  
    3636         * Client version.
    3737         */
    38         const CLIENT_VERSION = "1.1.15";
     38        const CLIENT_VERSION = "1.1.17";
    3939
    4040        /**
  • cardgate/trunk/cardgate.php

    r2588602 r2781410  
    77 * Author: CardGate
    88 * Author URI: https://www.cardgate.com
    9  * Version: 3.1.21
     9 * Version: 3.1.22
    1010 * Text Domain: cardgate
    1111 * Domain Path: /i18n/languages
    1212 * Requires at least: 4.4
    13  * WC requires at least: 2.1.0
    14  * WC tested up to: 5.6.0
     13 * WC requires at least: 3.0.0
     14 * WC tested up to: 6.8.2
    1515 * License: GPLv3 or later
    1616 */
  • cardgate/trunk/classes/CGP_Common_Gateway.php

    r2532998 r2781410  
    2020    var $logo;
    2121    var $bSeperateSalesTax;
     22    var $instructions;
    2223
    2324    // ////////////////////////////////////////////////
     
    2728        $this->title = (isset($this->settings['title']) && !empty($this->settings['title']) ? $this->settings['title'] : $this->payment_name);
    2829        $this->description = $this->settings['description'];
     30        $this->instructions = (!empty($this->settings['instructions']) ? $this->settings['instructions'] : '');
    2931
    3032        add_filter ( 'woocommerce_gateway_icon', array($this, 'modify_icon'), 20, 2 );
    3133        add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) );
    3234        add_action( 'woocommerce_receipt_' . $this->id, array( $this, 'receiptPage' ) );
     35        add_action( 'woocommerce_thankyou_' . $this->id, array( $this, 'thankyou_page' ) );
    3336    }
    3437
     
    4447        }
    4548    }
     49
     50    /**
     51     * Output for the order received page.
     52     */
     53    public function thankyou_page() {
     54        if ( $this->instructions ) {
     55            echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) );
     56        }
     57    }
    4658
    4759    // ////////////////////////////////////////////////
     
    147159                'default'     => __( 'Pay with ', 'cardgate' ) . $this->payment_name,
    148160                'desc_tip'    => true
    149             ]
     161            ],
     162            'instructions'       => [
     163                'title'       => __( 'Instructions', 'cardgate' ),
     164                'type'        => 'textarea',
     165                'description' => __( 'Instructions that will be added to the thank you page.', 'cardgate' ),
     166                'default'     => __( '', 'cardgate' ),
     167                'desc_tip'    => true
     168            ]
    150169        ];
    151170    }
     
    180199    public function process_payment( $iOrderId ) {
    181200        global $woocommerce;
    182 
    183201        try {
    184202
     
    546564                $sModel   = $this->formatSku( $oProduct );
    547565                $iQty     = $oItem->get_quantity();
    548                 $iPrice   = round( ( $oItem->get_total() * 100 ) / $iQty );
    549                 $iTax     = round( ( $oItem->get_total_tax() * 100 ) / $iQty );
     566                $iPrice   = round( ( $oItem->get_subtotal() * 100 ) / $iQty );
     567                $iTax     = round( ( $oItem->get_subtotal_tax() * 100 ) / $iQty );
    550568                $iTotal   = round( $iPrice + $iTax );
    551569                $iTaxrate = $this->get_tax_rate( $oProduct );
     
    577595
    578596        $iShippingTotal    = 0;
    579         $iShippingVatTotal = 0;
     597        $ishippingTaxTotal = 0;
    580598
    581599        $aShipping_methods = $oOrder->get_shipping_methods();
     
    610628
    611629                $iShippingTotal    = $iPrice;
    612                 $iShippingVatTotal = $iTax;
     630                $ishippingTaxTotal = $iTax;
    613631            }
    614632        }
     
    629647        }
    630648
    631         $iTaxDifference = round( $oOrder->get_total_tax() * 100 ) - $iCartItemTaxTotal - $iShippingVatTotal;
     649        $iDiscountTotal = 0;
     650        $iDiscountTaxTotal = 0;
     651
     652        $aOrderData = $oOrder->get_data();
     653        if ( $aOrderData['discount_total'] > 0 ) {
     654            $iDiscountTaxTotal = round($aOrderData['discount_tax'] * -100);
     655            $iDiscountTotal = round($aOrderData['discount_total'] * -100);
     656            $iDiscountVat = round($aOrderData['discount_tax'] / $aOrderData['discount_total'] * 100);
     657
     658            $nr ++;
     659            $items[ $nr ]['type']       = 'discount';
     660            $items[ $nr ]['model']      = 'discount_total';
     661            $items[ $nr ]['name']       = 'Discount';
     662            $items[ $nr ]['quantity']   = 1;
     663            $items[ $nr ]['price_wt']   = $iDiscountTotal;
     664            $items[ $nr ]['vat']        = $iDiscountVat;
     665            $items[ $nr ]['vat_amount'] = $iDiscountTaxTotal;
     666        }
     667
     668        $iTaxDifference = round( $oOrder->get_total_tax() * 100 ) - $iCartItemTaxTotal - $ishippingTaxTotal - $iDiscountTaxTotal;
    632669        if ( $iTaxDifference != 0 ) {
    633670            $nr ++;
     
    641678        }
    642679
    643         $iCorrection = round( $iOrderTotal - $iCartItemTotal - $iCartItemTaxTotal - $iShippingTotal - $iShippingVatTotal - $iExtraFee - $iTaxDifference );
     680        $iCorrection = round( $iOrderTotal - $iCartItemTotal - $iCartItemTaxTotal - $iShippingTotal - $ishippingTaxTotal - $iExtraFee - $iTaxDifference - $iDiscountTotal - $iDiscountTaxTotal);
    644681
    645682        if ( $iCorrection != 0 ) {
  • cardgate/trunk/readme.txt

    r2665824 r2781410  
    55Requires at least: 4.4
    66Tested up to: 5.9
    7 Stable tag: 3.1.21
     7Stable tag: 3.1.22
    88License: GPLv3 or later
    99License URI: https://www.gnu.org/licenses/gpl-3.0.html
     
    7575
    7676== Changelog ==
     77
     78= 3.1.22 =
     79* Added: Instructions field
     80* Added: Discount items
     81* update: Client Lib
    7782
    7883= 3.1.21 =
Note: See TracChangeset for help on using the changeset viewer.