Changeset 2911313
- Timestamp:
- 05/11/2023 06:16:35 PM (3 years ago)
- Location:
- woo-cost-of-shipping
- Files:
-
- 35 added
- 4 edited
-
tags/1.4.0 (added)
-
tags/1.4.0/README.txt (added)
-
tags/1.4.0/assets (added)
-
tags/1.4.0/assets/README.md (added)
-
tags/1.4.0/assets/css (added)
-
tags/1.4.0/assets/css/woocommerce-cost-of-shipping.css (added)
-
tags/1.4.0/assets/js (added)
-
tags/1.4.0/assets/js/index.js (added)
-
tags/1.4.0/assets/js/woocommerce-cost-of-shipping.js (added)
-
tags/1.4.0/assets/js/woocommerce-cost-of-shipping.min.js (added)
-
tags/1.4.0/assets/repo (added)
-
tags/1.4.0/assets/repo/README.md (added)
-
tags/1.4.0/includes (added)
-
tags/1.4.0/includes/README.md (added)
-
tags/1.4.0/includes/admin (added)
-
tags/1.4.0/includes/admin/class-wc-cos-admin-orders.php (added)
-
tags/1.4.0/includes/admin/class-wc-cos-admin.php (added)
-
tags/1.4.0/includes/admin/class-wc-cos-safe-domdocument.php (added)
-
tags/1.4.0/languages (added)
-
tags/1.4.0/languages/woocommerce-cost-of-shipping.pot (added)
-
tags/1.4.0/vendor (added)
-
tags/1.4.0/vendor/autoload.php (added)
-
tags/1.4.0/vendor/composer (added)
-
tags/1.4.0/vendor/composer/ClassLoader.php (added)
-
tags/1.4.0/vendor/composer/LICENSE (added)
-
tags/1.4.0/vendor/composer/autoload_classmap.php (added)
-
tags/1.4.0/vendor/composer/autoload_namespaces.php (added)
-
tags/1.4.0/vendor/composer/autoload_psr4.php (added)
-
tags/1.4.0/vendor/composer/autoload_real.php (added)
-
tags/1.4.0/vendor/composer/autoload_static.php (added)
-
tags/1.4.0/vendor/composer/installed.json (added)
-
tags/1.4.0/woo-includes (added)
-
tags/1.4.0/woo-includes/class-wc-cos-dependencies.php (added)
-
tags/1.4.0/woo-includes/woo-functions.php (added)
-
tags/1.4.0/woocommerce-cost-of-shipping.php (added)
-
trunk/README.txt (modified) (3 diffs)
-
trunk/assets/js/woocommerce-cost-of-shipping.js (modified) (1 diff)
-
trunk/includes/admin/class-wc-cos-admin-orders.php (modified) (3 diffs)
-
trunk/woocommerce-cost-of-shipping.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
woo-cost-of-shipping/trunk/README.txt
r2345609 r2911313 4 4 Tags: cost of shipping, shipping cost, WooCommerce, net profit, shipstation 5 5 Requires at least: 4.8.1 6 Tested up to: 5.46 Tested up to: 6.2 7 7 Requires PHP: 7.0 8 8 Stable tag: trunk … … 60 60 == Changelog == 61 61 62 = 1.4.1 = 63 - Security update 64 62 65 = 1.4.0 = 63 66 - Tweak: New function to work with the new more dynamic version of WooCommerce Net Profit. … … 93 96 == Upgrade Notice == 94 97 98 = 1.4.1 = 99 - Security update 100 95 101 = 1.4.0 = 96 102 - 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 }); 1 window.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 190 190 } 191 191 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' ); 193 196 194 197 // 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' ) ){ 196 199 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' ); 198 201 wp_send_json_success(); 199 202 wp_die(); … … 227 230 $this->log->add( 'the-rite-sites-profit-plugins', sprintf( __( ' Cost of shipping: %.2f via method: %s', 'woocommerce-cost-of-shipping' ), $cos, $method ) ); 228 231 } 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 ); 231 234 232 235 do_action( 'wc_cos_before_cost_of_shipping_stored', $order_id, $cos, $method ); … … 418 421 } 419 422 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 ); 421 426 422 427 // 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 ); 425 430 wp_send_json_success( array( 'cost' => $cost, 'currency' => get_woocommerce_currency_symbol() ) ); 426 431 wp_die(); 427 432 } 428 433 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 ); 430 435 wp_send_json_success( array( 'message' => 'No labels exist.' ) ); 431 436 wp_die(); -
woo-cost-of-shipping/trunk/woocommerce-cost-of-shipping.php
r2345609 r2911313 4 4 * Plugin URI: https://www.theritesites.com/plugins/woocommerce-cost-of-shipping 5 5 * Description: Allows the association of the cost of shipping to WooCommerce orders 6 * Version: 1.4. 06 * Version: 1.4.1 7 7 * Author: TheRiteSites 8 8 * Author URI: https://www.theritesites.com … … 11 11 * Text Domain: woocommerce-cost-of-shipping 12 12 * Domain Path: /languages 13 * WC tested up to: 4.313 * WC tested up to: 7.7 14 14 * WC requires at least: 3.0 15 15 * … … 17 17 * 18 18 * @package WC_COS 19 * @version 1.4. 019 * @version 1.4.1 20 20 */ 21 21 … … 25 25 * developed by TheRiteSites and found at https://www.theritesites.com/plugins/woocommerce-net-profit 26 26 * 27 * Copyright (c) 2020 TheRiteSites (email : contact@theritesites.com)27 * Copyright (c) 2020,2022 TheRiteSites (email : contact@theritesites.com) 28 28 * 29 29 * This program is free software; you can redistribute it and/or modify … … 43 43 44 44 45 // Use composer autoload.46 require 'vendor/autoload.php';47 45 48 46 if ( ! function_exists( 'is_woocommerce_active' ) ) { … … 63 61 * @since 1.0.0 64 62 */ 65 const VERSION = '1.4. 0';63 const VERSION = '1.4.1'; 66 64 67 65 /** … … 153 151 */ 154 152 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'; 155 156 // $this->plugin_class = new WCCOS_Plugin_Class( $this ); 156 157 $this->WC_COS_Admin = new WC_COS_Admin( $this );
Note: See TracChangeset
for help on using the changeset viewer.