Skip to content

Commit

Permalink
Merge pull request #60 from luizbills/luizbills-patch-2
Browse files Browse the repository at this point in the history
  • Loading branch information
luizbills authored May 24, 2023
2 parents cd96fa0 + 6d0365e commit 612db25
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions classes/Shortcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,23 @@ public function render_shortcode ( $atts ) {
], $atts, self::get_tag() );

$atts['product'] = absint( $atts['product'] );
$prod = null;
if ( 0 === $atts['product'] ) {
global $product;
$prod = $product;
$product = null;
if ( $atts['product'] !== 0 ) {
$product = wc_get_product( $atts['product'] );
} else {
$prod = wc_get_product( $atts['product'] );
$product = $GLOBALS['product'] ?? null;
}

if ( $prod && h::product_needs_shipping( $prod ) ) {
if ( is_object( $product ) && h::product_needs_shipping( $product ) ) {
do_action( 'wc_shipping_simulator_shortcode_included', $atts );

$this->enqueue_scripts();

return h::get_template( 'shipping-simulator-form', [
'ajax_url' => admin_url( 'admin-ajax.php' ),
'ajax_action' => Request::get_ajax_action(),
'product_type' => $prod->get_type(),
'product_id' => $prod->get_id(),
'product_type' => $product->get_type(),
'product_id' => $product->get_id(),

// customizable template variables
'input_placeholder' => apply_filters(
Expand Down

0 comments on commit 612db25

Please sign in to comment.