Fix: Prevent adding hidden input to external product forms with URLs
This commit addresses an issue where a hidden input field was being added unnecessarily to external product forms that already have a URL. The changes include: 1. Adding a check to determine if the product is an external product with a URL. 2. Only adding the hidden input field for products that are not external products with URLs. This fix ensures that external product forms with URLs maintain their intended functionality without the addition of unnecessary form elements.
This commit is contained in:
parent
9d76114472
commit
68ec22c2c2
|
@ -73,6 +73,8 @@ class AddToCartForm extends AbstractBlock {
|
|||
return '';
|
||||
}
|
||||
|
||||
$is_external_product_with_url = $product instanceof \WC_Product_External && $product->get_product_url();
|
||||
|
||||
ob_start();
|
||||
|
||||
/**
|
||||
|
@ -92,7 +94,10 @@ class AddToCartForm extends AbstractBlock {
|
|||
|
||||
$parsed_attributes = $this->parse_attributes( $attributes );
|
||||
$is_descendent_of_single_product_block = $parsed_attributes['isDescendentOfSingleProductBlock'];
|
||||
$product = $this->add_is_descendent_of_single_product_block_hidden_input_to_product_form( $product, $is_descendent_of_single_product_block );
|
||||
|
||||
if ( ! $is_external_product_with_url ) {
|
||||
$product = $this->add_is_descendent_of_single_product_block_hidden_input_to_product_form( $product, $is_descendent_of_single_product_block );
|
||||
}
|
||||
|
||||
$classname = $attributes['className'] ?? '';
|
||||
$classes_and_styles = StyleAttributesUtils::get_classes_and_styles_by_attributes( $attributes );
|
||||
|
|
Loading…
Reference in New Issue