Plugin Directory

Changeset 2911313


Ignore:
Timestamp:
05/11/2023 06:16:35 PM (3 years ago)
Author:
theritesites
Message:

1.4.1 security update

Location:
woo-cost-of-shipping
Files:
35 added
4 edited

Legend:

Unmodified
Added
Removed
  • woo-cost-of-shipping/trunk/README.txt

    r2345609 r2911313  
    44Tags:              cost of shipping, shipping cost, WooCommerce, net profit, shipstation
    55Requires at least: 4.8.1 
    6 Tested up to:      5.4
     6Tested up to:      6.2
    77Requires PHP:      7.0
    88Stable tag:        trunk
     
    6060== Changelog ==
    6161
     62= 1.4.1 =
     63- Security update
     64
    6265= 1.4.0 =
    6366- Tweak: New function to work with the new more dynamic version of WooCommerce Net Profit.
     
    9396== Upgrade Notice ==
    9497
     98= 1.4.1 =
     99- Security update
     100
    95101= 1.4.0 =
    96102- New capabilities to integrate with reporting
  • woo-cost-of-shipping/trunk/assets/js/woocommerce-cost-of-shipping.js

    r2227477 r2911313  
    1 /**
    2  * WooCommerce Cost of Shipping
    3  * https://www.theritesites.com/plugins/woocomerce-cost-of-shipping
    4  *
    5  * This plugin can be expanded into net profit reporting by getting the WooCommerce Net Profit plugin
    6  * developed by TheRiteSites and found at https://www.theritesites.com/plugins/woocommerce-net-profit
    7  *
    8  * Licensed under the GPLv2+ license.
    9  */
    10 
    11 window.WCCOS = window.WCCOS || {};
    12 
    13 ( function( window, document, $, plugin ) {
    14     var $c = {};
    15 
    16     plugin.init = function() {
    17         plugin.cache();
    18         plugin.bindEvents();
    19     };
    20 
    21     plugin.cache = function() {
    22         $c.window = $( window );
    23         $c.body = $( document.body );
    24     };
    25 
    26     plugin.bindEvents = function() {
    27     };
    28 
    29     $( plugin.init );
    30    
    31    
    32 }( window, document, jQuery, window.WCCOS ) );
    33 
    34 jQuery(document).ready(function( $ ) {
    35     'use strict';
    36    
    37     $('#edit-shipping-cost').on('click', function(e) {
    38         e.preventDefault();
    39         $('.edit-shipping-tooltip').toggle();
    40         $('#shipping-cost-input').focus();
    41     });
    42    
    43     $('#edit-shipping-cancel').on('click', function(e) {
    44         e.preventDefault();
    45         $('.edit-shipping-tooltip').toggle();
    46     });
    47    
    48     $('#edit-shipping-save').on('click', function(e) {
    49         e.preventDefault();
    50 
    51         $('#edit-shipping-save').attr( 'disabled', true );
    52         $('#edit-shipping-cancel').attr( 'disabled', true );
    53 
    54         var data = {
    55             action: 'set_shipping_cost',
    56             security: WCCOSApi.nonce,
    57             post_id: $('#edit-shipping-cost').data('orderid'),
    58             shipping_cost: $('#shipping-cost-input').val()
    59         };
    60 
    61         $.post( ajaxurl, data, function(response)  {
    62             if( WCCOSApi.debug )
    63                 console.log("Shipping cost sent!");
    64         })
    65         .done(function() {
    66             $('#edit-shipping-save').attr( 'disabled', false );
    67             $('#edit-shipping-cancel').attr( 'disabled', false );
    68             $('.edit-shipping-tooltip').toggle();
    69         })
    70         .fail(function() {
    71             console.log("Failed to save the shipping cost from manual input.");
    72         })
    73         .success(function() {
    74             if( WCCOSApi.debug )
    75                 console.log("success");
    76             var new_cos = parseFloat($('#shipping-cost-input').val()).toFixed(2);
    77             $('#shipping-cost .amount').html(
    78                 '<span class="woocommerce-Price-currencySymbol">' + WCCOSApi.currency + '</span>' + new_cos
    79             );
    80         })
    81         .always(function() {
    82            
    83         });
    84     });
    85 
    86     $('.wc-cos-wcs-import').on('click', function(e){
    87         e.preventDefault();
    88         console.log();
    89         var data = {
    90             action: 'set_label_cost_wcs',
    91             security: WCCOSApi.nonce,
    92             post_id: $(this).data('orderid'),
    93         };
    94 
    95         $('.wc-cos-wcs-import').prop('disabled', true);
    96         $(this).html('Loading...');
    97 
    98         $.post( ajaxurl, data, function(response)  {
    99             if( WCCOSApi.debug )
    100                 console.log("Shipping cost being imported!");
    101         })
    102         .done(function() {
    103             $('#wc-cos-protip').remove();
    104             $('.wc-cos-wcs-import').attr('disabled', false);
    105             $('.wc-cos-wcs-import').after('<div id="wc-cos-protip"><p><b>Pro tip:</b> If you purchase your label(s) and then set the order status to complete, the cost of shipping will automatically be imported!</p></div>');
    106         })
    107         .fail(function() {
    108             console.log("failed to import shipping cost from WooCommerce services created label.");
    109             $('.wc-cos-wcs-import').html('Retry import');
    110         })
    111         .success(function(response) {
    112             if( WCCOSApi.debug )
    113                 console.log("Success");
    114             $('.wc-cos-wcs-import').html('Re-import');
    115             $('.shipping-total .woocommerce-Price-amount').html(
    116                 '<span class="woocommerce-Price-currencySymbol">' + response['data']['currency'] + '</span>' + (parseFloat(response['data']['cost'])).toFixed(2)
    117             );
    118         });
    119     });
    120    
    121 });
     1window.WCCOS=window.WCCOS||{},function(i,o,t,c){var e={};c.init=function(){c.cache(),c.bindEvents()},c.cache=function(){e.window=t(i),e.body=t(o.body)},c.bindEvents=function(){},t(c.init)}(window,document,jQuery,window.WCCOS),jQuery(document).ready((function(i){"use strict";i("#edit-shipping-cost").on("click",(function(o){o.preventDefault(),i(".edit-shipping-tooltip").toggle(),i("#shipping-cost-input").focus()})),i("#edit-shipping-cancel").on("click",(function(o){o.preventDefault(),i(".edit-shipping-tooltip").toggle()})),i("#edit-shipping-save").on("click",(function(o){o.preventDefault(),i("#edit-shipping-save").attr("disabled",!0),i("#edit-shipping-cancel").attr("disabled",!0);var t={action:"set_shipping_cost",security:WCCOSApi.nonce,post_id:i("#edit-shipping-cost").data("orderid"),shipping_cost:i("#shipping-cost-input").val()};i.post(ajaxurl,t,(function(i){WCCOSApi.debug&&console.log("Shipping cost sent!")})).done((function(){i("#edit-shipping-save").attr("disabled",!1),i("#edit-shipping-cancel").attr("disabled",!1),i(".edit-shipping-tooltip").toggle()})).fail((function(){console.log("Failed to save the shipping cost from manual input.")})).success((function(){WCCOSApi.debug&&console.log("success");var o=parseFloat(i("#shipping-cost-input").val()).toFixed(2);i("#shipping-cost .amount").html('<span class="woocommerce-Price-currencySymbol">'+WCCOSApi.currency+"</span>"+o)})).always((function(){}))})),i(".wc-cos-wcs-import").on("click",(function(o){o.preventDefault(),console.log();var t={action:"set_label_cost_wcs",security:WCCOSApi.nonce,post_id:i(this).data("orderid")};i(".wc-cos-wcs-import").prop("disabled",!0),i(this).html("Loading..."),i.post(ajaxurl,t,(function(i){WCCOSApi.debug&&console.log("Shipping cost being imported!")})).done((function(){i("#wc-cos-protip").remove(),i(".wc-cos-wcs-import").attr("disabled",!1),i(".wc-cos-wcs-import").after('<div id="wc-cos-protip"><p><b>Pro tip:</b> If you purchase your label(s) and then set the order status to complete, the cost of shipping will automatically be imported!</p></div>')})).fail((function(){console.log("failed to import shipping cost from WooCommerce services created label."),i(".wc-cos-wcs-import").html("Retry import")})).success((function(o){WCCOSApi.debug&&console.log("Success"),i(".wc-cos-wcs-import").html("Re-import"),i(".shipping-total .woocommerce-Price-amount").html('<span class="woocommerce-Price-currencySymbol">'+o.data.currency+"</span>"+parseFloat(o.data.cost).toFixed(2))}))}))}));
  • woo-cost-of-shipping/trunk/includes/admin/class-wc-cos-admin-orders.php

    r2345609 r2911313  
    190190        }
    191191
    192         do_action( 'wc_cos_before_ajax_set_shipping_cost', $_POST['post_id'], $_POST['shipping_cost'], 'manual' );
     192        $post_id = intval( sanitize_text_field( $_POST['post_id'] ) );
     193        $cos     = floatval( sanitize_text_field( $_POST['shipping_cost'] ) );
     194
     195        do_action( 'wc_cos_before_ajax_set_shipping_cost', $post_id, $cos, 'manual' );
    193196       
    194197        // Returns true on success, false on anything else
    195         if ( $this->store_cost_of_shipping( $_POST['post_id'], $_POST['shipping_cost'], 'manual' ) ){
     198        if ( $this->store_cost_of_shipping( $post_id, $cos, 'manual' ) ){
    196199           
    197             do_action( 'wc_cos_after_ajax_set_shipping_cost', $_POST['post_id'], $_POST['shipping_cost'], 'manual' );
     200            do_action( 'wc_cos_after_ajax_set_shipping_cost', $post_id, $cos, 'manual' );
    198201            wp_send_json_success();
    199202            wp_die();
     
    227230            $this->log->add( 'the-rite-sites-profit-plugins', sprintf( __( '       Cost of shipping: %.2f via method: %s', 'woocommerce-cost-of-shipping' ), $cos, $method ) );
    228231        }
    229         $cos = apply_filters( 'wc_cos_store_cost_of_shipping', $cos );
    230         $method = apply_filters( 'wc_cos_store_cost_of_shipping_method', $method );
     232        $cos = apply_filters( 'wc_cos_store_cost_of_shipping', $cos, $order_id );
     233        $method = apply_filters( 'wc_cos_store_cost_of_shipping_method', $method, $order_id );
    231234       
    232235        do_action( 'wc_cos_before_cost_of_shipping_stored', $order_id, $cos, $method );
     
    418421        }
    419422
    420         do_action( 'wc_cos_before_ajax_set_label_cost_wcs', $_POST['post_id'] );
     423        $post_id = intval( sanitize_text_field( $_POST['post_id'] ) );
     424
     425        do_action( 'wc_cos_before_ajax_set_label_cost_wcs', $post_id );
    421426       
    422427        // Returns true on success, false on anything else
    423         if ( $cost = $this->maybe_save_order_shipping_cost_woocommerce_services( sanitize_text_field( $_POST['post_id'] ) ) ) {
    424             do_action( 'wc_cos_after_ajax_set_label_cost_wcs', $_POST['post_id'] );
     428        if ( $cost = $this->maybe_save_order_shipping_cost_woocommerce_services( $post_id ) ) {
     429            do_action( 'wc_cos_after_ajax_set_label_cost_wcs', $post_id );
    425430            wp_send_json_success( array( 'cost' => $cost, 'currency' => get_woocommerce_currency_symbol() ) );
    426431            wp_die();
    427432        }
    428433        elseif ( false === $cost ) {
    429             do_action( 'wc_cos_after_ajax_no_labels_wcs', $_POST['post_id'] );
     434            do_action( 'wc_cos_after_ajax_no_labels_wcs', $post_id );
    430435            wp_send_json_success( array( 'message' => 'No labels exist.' ) );
    431436            wp_die();
  • woo-cost-of-shipping/trunk/woocommerce-cost-of-shipping.php

    r2345609 r2911313  
    44 * Plugin URI:  https://www.theritesites.com/plugins/woocommerce-cost-of-shipping
    55 * Description: Allows the association of the cost of shipping to WooCommerce orders
    6  * Version:     1.4.0
     6 * Version:     1.4.1
    77 * Author:      TheRiteSites
    88 * Author URI:  https://www.theritesites.com
     
    1111 * Text Domain: woocommerce-cost-of-shipping
    1212 * Domain Path: /languages
    13  * WC tested up to: 4.3
     13 * WC tested up to: 7.7
    1414 * WC requires at least: 3.0
    1515 *
     
    1717 *
    1818 * @package WC_COS
    19  * @version 1.4.0
     19 * @version 1.4.1
    2020 */
    2121
     
    2525 * developed by TheRiteSites and found at https://www.theritesites.com/plugins/woocommerce-net-profit
    2626 *
    27  * Copyright (c) 2020 TheRiteSites (email : contact@theritesites.com)
     27 * Copyright (c) 2020,2022 TheRiteSites (email : contact@theritesites.com)
    2828 *
    2929 * This program is free software; you can redistribute it and/or modify
     
    4343
    4444
    45 // Use composer autoload.
    46 require 'vendor/autoload.php';
    4745
    4846if ( ! function_exists( 'is_woocommerce_active' ) ) {
     
    6361     * @since  1.0.0
    6462     */
    65     const VERSION = '1.4.0';
     63    const VERSION = '1.4.1';
    6664
    6765    /**
     
    153151     */
    154152    public function plugin_classes() {
     153        require_once plugin_dir_path( __FILE__ ) . 'includes/admin/class-wc-cos-admin.php';
     154        require_once plugin_dir_path( __FILE__ ) . 'includes/admin/class-wc-cos-admin-orders.php';
     155        require_once plugin_dir_path( __FILE__ ) . 'includes/admin/class-wc-cos-safe-domdocument.php';
    155156        // $this->plugin_class = new WCCOS_Plugin_Class( $this );
    156157        $this->WC_COS_Admin = new WC_COS_Admin( $this );
Note: See TracChangeset for help on using the changeset viewer.