Skip to content

Commit

Permalink
Tests, composer update. Plugin review.
Browse files Browse the repository at this point in the history
  • Loading branch information
dennisnissle committed Sep 27, 2024
1 parent 84b0ed1 commit 011de45
Show file tree
Hide file tree
Showing 99 changed files with 634 additions and 563 deletions.
3 changes: 2 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
/node_modules* export-ignore
/tests export-ignore
/bin export-ignore
/composer.* export-ignore
/composer-lock.* export-ignore
/phpcs.xml export-ignore
/phpunit.* export-ignore
/.phpunit.* export-ignore
/renovate.json export-ignore
/package.json export-ignore
/webpack.config.js export-ignore
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Thumbs.db
/vendor/composer/*

composer.lock
.phpunit.result.cache

# Packages
/packages/*
Expand Down
50 changes: 50 additions & 0 deletions assets/css/admin.scss
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,56 @@ table.wc-shiptastic-shipping-rules {
}
}

.wc-shiptastic-create-packaging-report {
margin-bottom: 15px;
padding: 0;

select {
width: auto !important;
min-width: 120px;
}

button.button {
height: 34px;
margin-left: 10px;
}
}

table.packaging_reports_table {
thead {
th {
padding: 10px;
}
td {
padding: 15px 10px;

.packaging-report-status {
margin-left: 5px;
}
}
}
}

tbody.packaging_list {
tr td {
padding: .5em;
}

select {
width: 100% !important;
}

.input-inner-wrap {
clear: both;

input.wc_input_decimal {
width: 33% !important;
min-width: auto !important;
float: left !important;
}
}
}

.packaging-report-status {
background: #f8dda7;
color: #94660c;
Expand Down
20 changes: 19 additions & 1 deletion assets/js/static/admin-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,29 @@ window.shiptastic.admin = window.shiptastic.admin || {};

$( document )
.on( 'click', 'a.woocommerce-stc-shipment-input-toggle-trigger', self.onInputToggleClick )
.on( 'change shiptastic_show_or_hide_fields', 'table.form-table :input[id]', self.onChangeInput );
.on( 'change shiptastic_show_or_hide_fields', 'table.form-table :input[id]', self.onChangeInput )
.on( 'click', '.wc_input_table a.add', self.onAddInputRow );

$( 'table.form-table :input[id]' ).trigger( 'shiptastic_show_or_hide_fields' );
},

onAddInputRow: function() {
var self = shipments.admin.shipment_settings,
$wrapper = $( this ).parents( '.wc_input_table' ),
size = $wrapper.find( 'tbody tr.item:visible' ).length,
$template = $wrapper.find( 'tr.template' ).clone();

$template.find( ':input' ).each( function() {
$( this ).attr('name', $( this ).attr( 'name' ).replace( 'size', size ) );
});

$template.appendTo( $wrapper.find( 'tbody' ) ).removeClass( 'template' ).show();

$( document.body ).trigger( 'wc-enhanced-select-init' );

return false;
},

getCleanInputId: function( $mainInput ) {
var self = shipments.admin.shipment_settings,
fieldId = $mainInput.attr( 'id' ) ? $mainInput.attr( 'id' ) : $mainInput.attr( 'name' );
Expand Down
4 changes: 4 additions & 0 deletions bin/vendor-clean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ fi
output 3 "Clean vendor dirs to save space..."

rm -rf ./vendor/dvdoug/boxpacker/visualiser/*
rm -rf ./vendor/dvdoug/boxpacker/docs/*
rm -rf ./vendor/dvdoug/boxpacker/features/*
rm -rf ./vendor/dvdoug/boxpacker/tests/data/*
rm -rf ./vendor/dvdoug/boxpacker/*.md
rm -rf ./vendor/dvdoug/boxpacker/.github/*

output 2 "Done!"
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@
"version": "dev-main",
"minimum-stability": "dev",
"require": {
"automattic/jetpack-autoloader": "^2.0.0",
"automattic/jetpack-autoloader": "2.11.18",
"setasign/fpdi": "^2.3",
"setasign/fpdf": "^1.8.2",
"dvdoug/boxpacker": "^3.9.0"
},
"require-dev": {
"phpunit/phpunit": "7.5.14",
"yoast/phpunit-polyfills": "^1.1.0",
"woocommerce/woocommerce-sniffs": "^0.1.3"
"phpunit/phpunit": "^9.0.0",
"yoast/phpunit-polyfills": "^3.0",
"woocommerce/woocommerce-sniffs": "^1.0.0"
},
"config": {
"optimize-autoloader": true,
"allow-plugins": true,
"platform": {
"php": "7.1"
"php": "7.4"
},
"preferred-install": "dist",
"sort-packages": true
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ services:
build:
context: ./tests/bin
ports:
- 8087:80
- 8089:80
restart: on-failure
environment:
WORDPRESS_DB_HOST:
Expand Down
2 changes: 1 addition & 1 deletion includes/admin/views/html-order-shipment-content.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@
<?php endif; ?>

<?php if ( $shipment->is_editable() ) : ?>
<a class="shipment-footer-action remove-shipment delete" href="#" data-id="<?php echo esc_attr( $shipment->get_id() ); ?>"><?php echo sprintf( esc_html_x( 'Delete %s', 'shipments', 'shiptastic-for-woocommerce' ), esc_html( wc_stc_get_shipment_label_title( $shipment->get_type() ) ) ); ?></a>
<a class="shipment-footer-action remove-shipment delete" href="#" data-id="<?php echo esc_attr( $shipment->get_id() ); ?>"><?php printf( esc_html_x( 'Delete %s', 'shipments', 'shiptastic-for-woocommerce' ), esc_html( wc_stc_get_shipment_label_title( $shipment->get_type() ) ) ); ?></a>
<?php endif; ?>

<?php
Expand Down
8 changes: 4 additions & 4 deletions includes/admin/views/html-preview-shipment.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
?>
<div class="wc-stc-preview-shipment">
<p class="shipment-summary">
<?php echo sprintf( esc_html_x( '%1$s %2$d/%3$d to ', 'shipments', 'shiptastic-for-woocommerce' ), esc_html( wc_stc_get_shipment_label_title( $shipment->get_type() ) ), esc_html( $position_number ), esc_html( $total_shipments ) ); ?>
<?php printf( esc_html_x( '%1$s %2$d/%3$d to ', 'shipments', 'shiptastic-for-woocommerce' ), esc_html( wc_stc_get_shipment_label_title( $shipment->get_type() ) ), esc_html( $position_number ), esc_html( $total_shipments ) ); ?>
<?php if ( ( $s_order = $shipment->get_order() ) && is_callable( array( $s_order, 'get_edit_order_url' ) ) ) : ?>
<a href="<?php echo esc_url( $s_order->get_edit_order_url() ); ?>"><?php echo sprintf( esc_html_x( '#%1$s', 'shipments', 'shiptastic-for-woocommerce' ), esc_html( $s_order->get_order_number() ) ); ?></a>
<a href="<?php echo esc_url( $s_order->get_edit_order_url() ); ?>"><?php printf( esc_html_x( '#%1$s', 'shipments', 'shiptastic-for-woocommerce' ), esc_html( $s_order->get_order_number() ) ); ?></a>
<?php else : ?>
<?php echo sprintf( esc_html_x( '#%1$s', 'shipments', 'shiptastic-for-woocommerce' ), esc_html( $shipment->get_order_number() ) ); ?>
<?php printf( esc_html_x( '#%1$s', 'shipments', 'shiptastic-for-woocommerce' ), esc_html( $shipment->get_order_number() ) ); ?>
<?php endif; ?>
</p>

Expand All @@ -34,7 +34,7 @@
if ( ! empty( $provider ) && ! empty( $tracking_id ) ) :
?>
<p>
<span class="shipment-shipping-provider"><?php echo sprintf( esc_html_x( 'via %s', 'shipments', 'shiptastic-for-woocommerce' ), wp_kses_post( wc_stc_get_shipping_provider_title( $provider ) ) ); ?></span>
<span class="shipment-shipping-provider"><?php printf( esc_html_x( 'via %s', 'shipments', 'shiptastic-for-woocommerce' ), wp_kses_post( wc_stc_get_shipping_provider_title( $provider ) ) ); ?></span>

<?php if ( $shipment->has_tracking() && ( $tracking_url = $shipment->get_tracking_url() ) ) : ?>
<a class="shipment-tracking-id" target="_blank" href="<?php echo esc_url( $tracking_url ); ?>"><?php echo esc_html( $tracking_id ); ?></a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,6 @@
defined( 'ABSPATH' ) || exit;
?>
<div class="wc-stc-shipment-label-admin-errors" id="wc-stc-shipment-label-admin-errors-<?php echo esc_attr( $provider->get_name() ); ?>">
<style>
.wc-backbone-modal-content footer {
display: none !important;
}
.wc-backbone-modal-main {
padding-bottom: 0;
}
</style>
<div class="notice-wrapper">
<?php foreach ( $error->get_error_messages() as $message ) : ?>
<div class="notice is-dismissible notice-warning">
Expand Down
2 changes: 1 addition & 1 deletion includes/emails/class-wc-stc-email-customer-shipment.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public function get_shipped_position_number( $shipment_id ) {
foreach ( $order->get_simple_shipments() as $key => $shipment ) {
if ( $shipment->is_shipped() ) {
if ( (int) $shipment->get_id() !== (int) $shipment_id ) {
$shipped_count++;
++$shipped_count;
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions includes/wc-stc-shipment-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -1548,12 +1548,12 @@ function wc_stc_get_shipment_error( $error ) {
}
}

function wc_shiptastic_substring( $string, $start, $length = null ) {
function wc_shiptastic_substring( $str, $start, $length = null ) {
if ( function_exists( 'mb_substr' ) ) {
$string = mb_substr( $string, $start, $length );
$str = mb_substr( $str, $start, $length );
} else {
$string = substr( $string, $start, $length );
$str = substr( $str, $start, $length );
}

return $string;
return $str;
}
3 changes: 1 addition & 2 deletions includes/wc-stc-template-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ function woocommerce_shiptastic_template_view_shipment( $shipment_id ) {
if ( ! function_exists( 'woocommerce_shiptastic_template_add_return_shipment' ) ) {

function woocommerce_shiptastic_template_add_return_shipment( $order_id ) {

if ( ( ! ( $order = wc_get_order( $order_id ) ) ) || ( ! wc_stc_customer_can_add_return_shipment( $order_id ) ) ) {
echo '<div class="woocommerce-error">' . esc_html_x( 'Invalid order.', 'shipments', 'shiptastic-for-woocommerce' ) . ' <a href="' . esc_url( wc_get_page_permalink( 'myaccount' ) ) . '" class="wc-forward">' . esc_html_x( 'My account', 'shipments', 'shiptastic-for-woocommerce' ) . '</a></div>';
return;
Expand All @@ -156,7 +155,7 @@ function woocommerce_shiptastic_template_add_return_shipment( $order_id ) {

// Output notices in case notices have not been outputted yet.
if ( ! empty( $notices ) ) {
echo '<div class="woocommerce">' . $notices . '</div>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo '<div class="woocommerce">' . wc_kses_notice( $notices ) . '</div>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}

wc_get_template(
Expand Down
23 changes: 22 additions & 1 deletion phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,28 @@
<exclude-pattern>*</exclude-pattern>
</rule>

<rule ref="WordPress.CodeAnalysis.AssignmentInCondition">
<rule ref="Generic.CodeAnalysis.AssignmentInCondition.Found">
<exclude-pattern>*</exclude-pattern>
</rule>

<rule ref="Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed">
<exclude-pattern>*</exclude-pattern>
</rule>

<rule ref="Generic.CodeAnalysis.UnusedFunctionParameter.Found">
<exclude-pattern>*</exclude-pattern>
</rule>

<rule ref="WordPress.WP.Capabilities">
<properties>
<property name="custom_capabilities" type="array">
<element value="manage_woocommerce" />
<element value="pay_for_order" />
<element value="view_order" />
<element value="edit_shop_orders" />
<element value="delete_shop_orders" />
<element value="edit_others_shop_orders" />
</property>
</properties>
</rule>
</ruleset>
Loading

0 comments on commit 011de45

Please sign in to comment.