Display product meta in popup or modal dialog or lightbox window.
-
Hello guys! Plz, I need your help!
What I want to do is:
In the product page (single product page) I have a button. Onclick, it must open a popup window or a lightbox, even a modal dialog, which displays some of the product details (product meta), such as SKU, weight, price per weight and total price.I have used a code I found about the button and the popup window.
First of all, I created a popup.js file inside the themes’ folder js and the code I used is:
jQuery(document).ready(function($) {
$(‘.popup’).click(function() {
var NWin = window.open($(this).prop(‘href’), ”, ‘scrollbars=1,height=400,width=400’);
if (window.focus)
{
NWin.focus();
}
return false;
});
});Then in the functions.php file:
//* Register and Enqueue scripts for popup
function cc_popup_script() {
wp_register_script( ‘popup’, get_stylesheet_directory_uri() . ‘/js/popup.js’, array( ‘jquery’ ), ‘1.0.0’, false );
wp_enqueue_script( ‘popup’ );
}add_action(‘wp_enqueue_scripts’, ‘cc_popup_script’);
Finally, inside the content-single-product.php what I need is sth like this:
<button>Weighing!</button>With this code popup window works fine, but instead of google URL, I need the permalink of a custom .php file, for example popup.php so I can get the product details (product meta), I need.
Can I do this by getting those product meta from wpdb (I am not sure how to do it). Am I headed in the right direction? If I can do that with a plugin, then even better!
Many thanks!
- The topic ‘Display product meta in popup or modal dialog or lightbox window.’ is closed to new replies.