我有一个WooCommerce网站,有几个产品由于他们订购了错误的东西而获得了大量的回报.我添加了一个"备忘单",客户可以通过高级自定义字段引用该备忘单.我已经编写了下面的代码,强制他们选中复选框以确认他们已经阅读了它,然后才能将产品添加到购物车中.
问题是,无论是否勾选方框,我都会显示自定义错误消息.显然我的逻辑有一个缺陷,但我无法确定它.
任何帮助将不胜感激.
<?php
// Add Confirmation Checkbox on Product Single
add_action( 'woocommerce_single_product_summary', 'woocommerce_cheat_sheet_confirm', 29 );
function woocommerce_cheat_sheet_confirm() {
global $post;
$cheat_sheet = get_field('cheat_sheet'); // Get Advanced Custom Field
if ( ! empty( $cheat_sheet ) ) { // If it exists, add the confirmation box ?>
<div id="cheat-sheet-confirmation" class="checkbox">
<form>
<label>
<input id="cheatsheetconfirm" name="cheatsheetconfirm" type="checkbox" value="isconfirmed"> I confirm that I have read the <a href="<?php echo $cheat_sheet['url']; ?>" />cheat sheet</a>.
</label>
</form>
</div>
<?php }
}
function cheatsheetConfirmation() {
if(isset($_REQUEST['cheatsheetconfirm']) …Run Code Online (Sandbox Code Playgroud) 我有一个将在php中生成的菜单,可以在其中包含两个不同的子div.简而言之,php将在"li"中添加一个类名为"showBubbles"的div,和/或另一个具有"hideLogo"类的div.如果存在"showBubbles"div,则需要执行一个函数,如果存在"hideLogo",则需要执行另一个函数.如何在鼠标悬停时执行此操作?结构如下所示:
<ul>
<li>
<a href="#"><img src="imagePlaceholder" /></a>
<div class="showBubbles"></div>
<div class="hideLogo"></div>
</li>
</ul>
Run Code Online (Sandbox Code Playgroud) 我正在编写一个简单的脚本来替换两个图像.第一个交换正常,但第二个由于某种原因不会开火.它必须是我想念的简单事物.也许'div.singleTint img'选择器?有人可以看看并仔细检查我的工作吗?
这是我的HTML:
<div id="beerGlassOverlay">
<img src="<?php bloginfo('template_directory'); ?>/images/beerOverlay.png" class="glassreplace">
</div>
<li class="image-rollover">
<a href="http://brasco.co/Mims/meet-the-breweries/miller-beers/" target="_blank">
<img width="177" height="186" src="http://brasco.co/Mims/wp-content/uploads/2012/05/miller1.png" class="attachment-full wp-post-image" alt="miller" title="miller" />
</a>
<div class="singleTint">
<img width="279" height="524" src="http://brasco.co/Mims/wp-content/uploads/shrekBeer.png" class="attachment-full" alt="shrekBeer" title="shrekBeer" />
</div><!-- End singleTint-->
</li>
Run Code Online (Sandbox Code Playgroud)
这是我的jQuery:
$('li.image-rollover').mouseover(function() {
$('img.glassreplace').attr({//Change the src and size info on hover
src: ('div.singleTint img', this).src,
width: '100%',
height: '100%'
});
});`
Run Code Online (Sandbox Code Playgroud)