How to update filed when click - wordpress

I use acf to creat 3 fields, below, i put 3 buttons to switch between 3 fields, problem is, i embed iframe to play video, when i play, even i clicked on another button, it still play on field 1, anyone can help me this ? i want when click on button, it will stop loading iframe from field 1, then replace with iframe from field 2. Tks, sorry for my bad english.
Here my code to show 3 fields...
<script type="text/javascript">
$(function() {
var $allItems = $(".food-container > div");
$(document.body).on("click", "a.button", function(evt) {
var id = this.id,
itemId = ".food-container > #item-" + id;
$allItems.not($(itemId).fadeToggle()).hide();
if (evt.target.id == 4) {
$('.burger-disclaimer').toggle();
} else {
$('.burger-disclaimer').hide();
}
});
});
</script>
<div class="food-container">
<div id="item-1" style="display: block;">
<div class="food"><iframe class="re-if" src="<?php the_field('sv1'); ?>"></iframe></div>
</div>
<div id="item-2" style="display: none;">
<div class="food"><iframe class="re-if" src="<?php the_field('sv2'); ?>"></iframe></div>
</div>
<div id="item-3" style="display: none;">
<div class="food"><iframe class="re-if" src="<?php the_field('sv3'); ?>"></iframe></div>
</div>
<a id="1" href="javascript:void(0)" class="button" onclick="pauseVideo()">Server 1<i class="fa fa-caret-right"></i></a>
<a id="2" href="javascript:void(0)" class="button" onclick="pauseVideo()">Server 2<i class="fa fa-caret-right"></i></a>
<a id="3" href="javascript:void(0)" class="button" onclick="pauseVideo()">Server 3<i class="fa fa-caret-right"></i></a>
<?php
$link = get_field('download');
if( $link ): ?>
<a class="button" href="<?php echo esc_url( $link ); ?> target=">Download</a>
<?php endif; ?>
</div>

Related

Quick View redirect to single product page not the quick view popup

can somebody help me how to do it? I need to rewrite some code of quick view i need if somebody push on the quick view icon they got redirected to single product page , not the quick view popup.
First Step
Second Step Change to Single of Third Step
Your quick view should be in <a> tag with the data-target="" in which data-target refers to the modal pop up display.
It should be something like this,
In your <a> tag.
<a class="gift" data-toggle="modal" data-title="<?php echo get_the_title();?>" data-content="<?php $content= get_the_content(); $content1=substr($content,0,20); echo wp_strip_all_tags($content1); echo "...";?>" data-target="#gift_pop" data-price="<?php echo '€'.$product->get_regular_price();?>" data-id="<?php echo $product->get_id();?>" data-image="<?php echo get_the_post_thumbnail_url($post->ID,'medium');?>" data-link="<?php the_permalink(); ?>"> <img src="<?php echo get_the_post_thumbnail_url($post->ID,'medium');?>" alt="">
</a>
In <a> tag itself we should get the data which should be shown in modal popup.
And this is My modal popup html code.
<div class="modal" id="gift_pop" role="dialog">
<div class="modal__content">
<div class="modal__wrapper">
<a class="modal__close" data-dismiss="modal">
<img src="<?php echo get_template_directory_uri(); ?>/images/login_close.png" alt="">
</a>
<div class="product_popup">
<div class="acc_img">
<img id="product_pop" src="">
</div>
<div class="acc_text">
<p id="product_title_pop"></p>
<div class="pro_lrt _fl">
<span id="product_price_pop"></span>
</div>
<p id="product_content_pop"></p>
<a id ="product_link_pop" href="">View Details.</a>
</div>
</div>
</div>
</div>
</div>
The Id of the modal popup should be the data-target value.
And finally the script to append the data which we got in <a> tag.
<script type="text/javascript">
//to append values in modal popup
$(".gift").click(function(){
var postId = $(this).data('id');
var image = $(this).data('image');
var title = $(this).data('title');
var content= $(this).data('content');
var price= $(this).data('price');
var link= $(this).data('link');
$('#product_pop').attr("src",image);
$('#product_title_pop').html(title);
$('#product_content_pop').html(content);
$('#product_price_pop').html(price);
$('#product_link_pop').attr("href",link);
});
</script>
And thats it! Enjoy.

How to refresh/reload WooCommerce checkout page after adding a coupon code (wordpress)?

I need to reload the entire WooCommerce checkout page after adding a coupon code.
I tried the following code but it doesn't reload it.
The reason why I need this function:
Prices of the review table turns to defalut language prices after adding the coupon code.
When I refresh the page, it shows translated language prices, so I need to reload it.
Would you please let me know how to reload it?
Added this code in a checkout page:
jQuery(document).ajaxComplete(function(event, xhr, settings) {
if (settings.url === '/?wc-ajax=apply_coupon') {
location.reload();
}
});
jQuery(document).ajaxComplete(function(event, xhr, settings) {
if (settings.url === '/?wc-ajax=apply_coupon') {
jQuery('body').trigger('update_checkout');
}
});
Order review table:
<div class="ea-woo-checkout-order-review">
<div class="ea-checkout-review-order-table">
<ul class="ea-order-review-table">
<li class="table-header">
<div class="table-col-1"></div>
<div class="table-col-2"></div>
<div class="table-col-3"></div>
</li>
<li class="table-row cart_item">
<div class="table-col-1 product-thum-name">
<div class="product-thumbnail">
<img width="300" height="200" src="https://www.myweb.com/wp-content/uploads/2021/06/LineOne_22-300x200.jpg" class="attachment-woocommerce_thumbnail size-woocommerce_thumbnail" alt="" loading="lazy"> </div>
<div class="product-name">Template Type </div>
</div>
<div class="table-col-2 product-quantity">1</div>
<div class="table-col-3 product-total"><span class="woocommerce-Price-amount amount"><bdi><span class="woocommerce-Price-currencySymbol">$</span>820,000</bdi></span></div>
</li>
</ul>
<div class="ea-order-review-table-footer">
<div class="footer-content">
<div class="cart-subtotal">
<div></div>
<div><span class="woocommerce-Price-amount amount"><bdi><span class="woocommerce-Price-currencySymbol">$</span>820,000</bdi></span></div>
</div>
<div class="order-total">
<div></div>
<div><strong><span class="woocommerce-Price-amount amount"><bdi><span class="woocommerce-Price-currencySymbol">$</span>820,000</bdi></span></strong> </div>
</div>
</div>
</div>
</div>
</div>
Apply coupon:
<div class="woo-checkout-coupon">
<div class="ea-coupon-icon"><i aria-hidden="true" class="fas fa-percent"></i></div>
<div class="woocommerce-form-coupon-toggle">
<div class="woocommerce-info">
Have a coupon? Click here to enter your code </div>
</div>
<form class="checkout_coupon woocommerce-form-coupon" method="post" style="">
<p>If you have a coupon code, please apply it below.</p>
<p class="form-row form-row-first">
<input type="text" name="coupon_code" class="input-text" placeholder="Coupon code" id="coupon_code" value="">
</p>
<p class="form-row form-row-last">
<button type="submit" class="button" name="apply_coupon" value="Apply Coupon">Apply Coupon</button>
</p>
<div class="clear"></div>
</form>
</div>
You should use
jQuery('body').trigger('update_checkout');
instead of
location.reload();
Alternative
add_action('wp_footer', 'woocommerce_custom_update_checkout', 50);
function woocommerce_custom_update_checkout()
{
if (is_checkout()) {
?>
<script type="text/javascript">
jQuery(document).ready($ => {
$('input').on('change', () => {
$('body').trigger('update_checkout');
});
});
</script>
In case someone who needs it
It's working with the following code:
jQuery( document.body ).on( 'applied_coupon_in_checkout removed_coupon_in_checkout', function () {
location.reload();
} );

Bootstrap Carousel ACF repeater - arrows not working

Good morning,
I'm currently developing on the understrap-child theme and I have an issue with a Bootstrap Carousel which I made into a repeater using Acf pro plug-in on Wordpress.
The issue is about the indicator arrows not working. The slider is perfectly working as a repeater, but the right arrow (carousel-control-next) does not work, only the left one allows me to interact with the slider.
I'm wondering if the issue is related to the repeater itself or with me making some stupid mistake I'm not able to see! PLEASE HELP ME
Here's my code:
<div class="container-fluid containerslider sliderdesktop container-home-sub ">
<div id="HomeCarouselIndicators" class="carousel slide" data-ride="carousel">
<!--indicators-->
<?php if( have_rows('slider') ): $i = 0; ?>
<ol class="carousel-indicators">
<?php while ( have_rows('slider') ): the_row(); ?>
<li data-target="#HomeCarouselIndicators" data-slide-to="<?php echo $i; ?>" class="<?php if($i == 0) echo 'active'; ?>"></li>
<?php $i++; endwhile; ?>
</ol>
<?php endif; ?>
<!--end of indicators-->
<div class="carousel-inner" role="listbox">
<?php // check if the repeater field has rows of data
$count = 0;
if( have_rows('slider') ){
//loop through
while ( have_rows('slider') ){
//define the row
the_row();
?>
<!-- Slide One - Set the background image for this slide in the line below -->
<div class="carousel-item subheader-carousel <?php if ($count==0) {echo "active";} ?>" style="background-image: url('<?php the_sub_field('slider_background'); ?>')" >
<div class="">
</div>
</div>
<a class="carousel-control-prev" href="#HomeCarouselIndicators" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#HomeCarouselIndicators" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
<?php
$count=$count+1;
}
}
?>
</div><!--end of carousel inner-->
</div><!--end of homecarouselindicators-->
</div><!--end container slider-->
At a glance, you have your controls inside your carousel-inner.
https://getbootstrap.com/docs/4.0/components/carousel/
Shows the controls being outside the carousel-inner but inside the carousel.

bootstrap - wordpress grid

I am making a wp custom theme with bootstrap. I implemented a grid to display the latest posts. I want to display 4 items in a row for larger screens (down to 768px = col-sm-3) and then 2 items per row (col-xs-6). It kinda works but at some point the items are not displaying properly. In particular, when the screen width is between 1200 - 768 or less than 579, 1 row every 4 is broken and only displays 1 item (see images). I'm not sure where the issue is.
I read about the .cleardiv class but I don't understand where I should put it.
You can see the website here. (Please note that the top row with the 4 items is working fine as it is generated before the other 12 in a different row). Just click the "v" arrow to display the rows with the issue.
Thanks
<section class="bg-white" id="in_evidenza">
<div class="container">
<!-- this is the first row which is always visible. no issue here -->
<div class="row"> ...
</div>
<!-- second row: issue here -->
<div class="row" id="news-content">
<?php
$args = array( 'numberposts' => '12', 'category_name' => 'news', 'orderby' => 'date', 'offset' => '4' );
$recent_posts = wp_get_recent_posts( $args );
$i = 1;
foreach( $recent_posts as $recent ):
$post_img_src = "http://www.assatena.it/testbs/wordpress/wp-content/uploads/2016/03/".$i.".png";
$post_title = $recent["post_title"];
$post_id = $recent["ID"];
$post_content = get_post_field('post_content', $post_id);
$post_date = get_the_date("d/m/Y", $post_id);
if(strlen($post_title) >= 19){
$post_title_short = substr($post_title, 0, 19);
$post_title_short.="...";
}else
$post_title_short = $post_title;
$teaser = substr(strip_tags($post_content), 0, 66);
$teaser.=" . . .";
?>
<div class="col-lg-3 col-md-3 col-sm-3 col-xs-6" id="col-news-all">
<div class="text-center">
<img class="img-rect" width="160" height="100" alt="" src='<?php echo $post_img_src; ?>' />
<h3><?php echo $post_title_short; ?></h3>
<p>
<?php echo $teaser; ?>
<br> <!-- open -->
<a data-toggle="modal" href="" data-target="#modal-news-<?php echo $post_id; ?>">
<span class="glyphicon glyphicon-volume-up" aria-hidden="true"></span>
</a>
</p>
</div>
</div>
<div id="modal-news-<?php echo $post_id; ?>" class="modal fade in" aria-hidden="false" role="dialog" tabindex="-1">
<div class="modal-content">
<div class="container">
<div class="row">
<div class="col-lg-10 col-lg-offset-1">
<div class="modal-body">
<h2><?php echo $post_title; ?></h2>
<p class="post_date">- <?php echo $post_date; ?> -</p>
<hr class="star-primary">
<img id="news_img" class="img-responsive img-modal" alt="News img" src="<?php echo $post_img_src; ?>" />
<div class=" text-left">
<div class="my_post_content">
<p><?php echo $post_content; ?></p>
</div>
</div>
<div class="text-center"> <!-- close -->
<a data-dismiss="modal" class="btn btn-success btn-xl ">Chiudi</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<?php
$i%=4;
$i++;
endforeach;
?>
</div> <!-- row -->
<div class="text-center">
<a data-toggle="modal" href="" data-target="">
<span id="news-all" class="glyphicon glyphicon-menu-down" aria-hidden="true"></span>
</a>
</div>
</div> <!-- container -->
</section>
images:
Before your $i++ write an if statement to place a clearfix
<?php if ($i % 4 == 0); ?>
<div class="clearfix"></div>
<?php endif; ?>
EDIT: for the mobile you can set another clearfix with $i % 2 == 0 and hide it in desktops via visible-xs

Woocommerce shop page custom css

I am new to woocommerce.I have a problem in product listing,when I add the shortcode It shows woocommerce html,class listing,But I want to display my html,css I tried but it is not not working ,Here is woocommerce code..
<ul class="products">
<li class="post-22 product type-product status-publish has-post-thumbnail first shipping-taxable purchasable product-type-simple product-cat-featured instock">
<a href="http://localhost/wordpress/?product=mac-2">
<img src="http://localhost/wordpress/wp-content/uploads/2015/02/2-240x300-240x300.jpg" class="attachment-shop_catalog wp-post-image" alt="2-240x300" height="300" width="240">
<h3>Mac 2</h3>
<span class="price"><span class="amount">£50.00</span></span>
</a>
Add to cart
</li>
Here is my code ..
<div class="box-product product-carousel" id="featured-tab-carousel">
<div class="slider-item">
<div>
<div class="product-block" id="element_change">
<div class="product-block-inner">
<div class="product-image-block">
<?php echo do_shortcode('[product_category category="featured" per_page="12" columns="4" orderby="default" order="ASC"]');?>
<div class="product-hover-block">
<div class="add-to-link">
<div class="cart">
<input type="button" value="Add to Cart" onclick="addToCart('43');" class="button" />
<em>Add to Cart</em>
</div>
<div class="wishlist"><a onclick="addToWishList('43');">Add to Wish List</a>
<em>Add to Wish List</em>
</div>
<div class="compare"><a onclick="addToCompare('43');">Add to Compare</a>
<em>Add to Compare</em>
</div>
</div>
<div class="rating"><img src="<?php echo get_template_directory_uri();?>/catalog/view/theme/OPC080180/<?php echo get_template_directory_uri();?>/image/stars-0.png" alt="Based on 0 reviews." /></div> </div>
</div>
<div class="product_category_title"> - Software</div>
<div class="name">MacBook</div>
<div class="product_info">
<div class="price">$589.50 </div>
</div></div></div>
Please help me how to change css...
This is said to work as a way to include a custom CSS Stylesheet for Woocommerce:
function enqueue_style_after_wc() {
$deps = class_exists( 'WooCommerce' ) ? array( 'woocommerce-layout', 'woocommerce-smallscreen', 'woocommerce-general' ) : array();
wp_enqueue_style( 'my-style', 'my-style.css', $deps, '1.0' );
}
add_action( 'wp_enqueue_scripts', 'enqueue_style_after_wc' );
Source: https://wordpress.stackexchange.com/questions/135171/woocommerce-include-custom-stylesheet-after-woocommerce-styling

Resources