Skip to content

Commit

Permalink
Added explicit builtin method check to prevent potential errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
dennisnissle committed Nov 13, 2024
1 parent 94fff3d commit a2185b1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -1362,7 +1362,7 @@ public function get_builtin_shipping_method() {
if ( 'shipping_provider_' === substr( $shipping_method_id, 0, 18 ) ) {
$the_method = $this->get_shipping_method();

if ( $the_method && ! $the_method->is_placeholder() ) {
if ( $the_method && $the_method->is_builtin_method() ) {
return $the_method;
}
}
Expand Down
12 changes: 10 additions & 2 deletions src/ShippingMethod/ProviderMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function get_method() {
* @return false|ShippingProvider
*/
public function get_shipping_provider_instance() {
if ( is_a( $this->method, '\Vendidero\Germanized\Shipments\ShippingMethod\ShippingMethod' ) ) {
if ( $this->is_builtin_method() ) {
return $this->method->get_shipping_provider();
}

Expand All @@ -98,8 +98,16 @@ public function get_shipping_provider_instance() {
return $this->provider ? $this->provider : false;
}

public function get_shipping_provider() {
public function is_builtin_method() {
if ( is_a( $this->method, '\Vendidero\Germanized\Shipments\ShippingMethod\ShippingMethod' ) ) {
return true;
}

return false;
}

public function get_shipping_provider() {
if ( $this->is_builtin_method() ) {
$provider_slug = $this->method->get_shipping_provider()->get_name();
} else {
$provider_slug = $this->get_prop( 'shipping_provider' );
Expand Down

0 comments on commit a2185b1

Please sign in to comment.