Good morning, I have the following code in functions.php
:
include('popup.php');
add_action( 'woocommerce_single_product_summary', 'boton_sub_producto_single', 6 );
function boton_sub_producto_single() {
global $product;
$nombre = $product->get_title();
if ( ! $product->is_in_stock() || ! $product->is_purchasable() ){
echo '<button type="button" class="button btn-info btn-lg" data-toggle="modal" data-target="#myModal" data-backdrop="static">Encuentra tu producto</button>';
}
return $product;
}
This shows me a button on the individual products page, all right here, I try to call the name of the product with the following variable $nombre = $product->get_title();
if I write there is same echo $nombre;
shows me the name of the product effectively.
Now when I click on the function button this opens a "bootstrap modal" popup that I have on another page called popup.php
with the following code:
<!DOCTYPE html>
<html lang="en">
<body>
<div class="container">
<!-- Trigger the modal with a button -->
<!-- <button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Open Modal</button>-->
<!-- Modal -->
<div class="modal fade" id="myModal" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Modal Header</h4>
</div>
<div class="modal-body">
<p>Some text in the modal.</p><?php
echo $nombre; ?>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
I want to print the name of the product here
<p>Some text in the modal.</p><?php
echo $nombre; ?>
But does not it show me anything - any way I could print the name of the product inside the popup?