WooCommerce产品页虚构库存数量和在线人数
wp-js代码,放入flatsome→theme options→WooCommerce→product→HTML before Add To Cart button
<style>.plugin_modals__list-name {border-bottom: 1px solid var(--list_border_color);border-top: 1px solid var(--list_border_color);--list_border_color: #dddddd;}li.pdr__rule {margin: 10px 0;list-style: none;line-height: 1.5;color: #212121;}li.pdr__rule b {color: #ff3333;}.product-info__body {--list_border_color: #dddddd;margin-top: 2rem;margin-bottom: 2rem;font-family: Roboto,sans-serif;font-style: normal;font-weight: 400;}.tw-w-full {
line-height: 1.5;
color: #212121;
margin: 10px 0px;}span.tw-ml-4.tw-leading-none {
margin-left: 1rem;}.plugin_modals__list-name li:nth-child(n+4) {
display: none;}.product_detail_rebate_list {//DISPLAY: NONE;}</style><div class="tw-mt-10 empty:tw-hidden product-info_marketing-tools">
<div class="tw-w-full tw-flex tw-mt-4 tw-items-center product-info__marketing-inventory" data-random="true" data-inventory-min="10" data-inventory-max="100">
<svg class=" " xmlns="http://www.w3.org/2000/svg" width="18px" height="18px" viewBox="0 0 18 18"><path d="M9.9730669,0.261485918 L16.027926,3.78188564 C16.6296388,4.13192538 17,4.77899886 17,5.47807823 L17,12.5208779 C17,13.2209574 16.6296388,13.8670307 16.0269331,14.2170705 L9.9730669,17.7374702 C9.37135409,18.0875099 8.62963882,18.0875099 8.02792602,17.7374702 L1.9730669,14.2170705 C1.37121415,13.8673133 1.00029526,13.2207495 1,12.5208779 L1,5.47807823 C1,4.77799874 1.37135411,4.13192538 1.9730669,3.78188564 L8.0269331,0.262486036 C8.62876178,-0.0874953454 9.37024529,-0.0874953454 9.97207397,0.262486036 L9.9730669,0.261485918 Z M15.6099044,6.16415612 L15.4063547,6.28416976 L9.69504779,9.60454676 L9.69504779,16.282305 L15.3328782,13.0049328 C15.5036614,12.9049215 15.6099044,12.7199005 15.6099044,12.5208779 L15.6099044,6.16415612 L15.6099044,6.16415612 Z M2.39009558,6.14515397 L2.39009558,12.5208779 C2.39009558,12.7209006 2.4963386,12.9049215 2.66811468,13.0049328 L8.30495221,16.282305 L8.30495221,9.58454448 L7.61884076,9.18549917 C7.62380539,9.18549917 7.62181953,9.18449906 7.61884076,9.18349896 L7.61784783,9.18549917 L2.39009558,6.14515397 Z M5.21695419,3.51085486 L2.930247,4.84300612 L8.30495221,7.96736087 L9.01489388,8.38140788 L11.302594,7.05125686 L5.21596128,3.51085486 L5.21695419,3.51085486 Z M8.72198089,1.47362355 L6.60704977,2.70376323 L12.6936825,6.24216499 L15.0866327,4.85200713 L9.27801911,1.47262345 L9.18865583,1.43061868 C9.03486007,1.37487343 8.86448882,1.39024101 8.7229738,1.47262345 L8.72198089,1.47362355 Z" fill="currentColor" fill-rule="evenodd" clip-rule="evenodd"></path>
</svg><span class="tw-ml-4 tw-leading-none">Only <b class="wp_cp_stock">14</b> left in stock</span>
</div>
<div class="tw-w-full tw-flex tw-items-center tw-mt-4 product-info__marketing-live-view BrowseNum" data-live-view-min="5" data-live-view-max="20" data-live-view-interval="3">
<svg class=" " xmlns="http://www.w3.org/2000/svg" width="18px" height="18px" viewBox="0 0 18 18"><path d="M9,3 C13.2986524,3 18,6.4825 18,8.99916666 C18.005557,11.5666667 13.3821575,15 9.00370632,15 C4.62432732,15 -2.48689958e-14,11.6833333 -2.48689958e-14,9 C-2.48689958e-14,6.265 4.54638922,3 9,3 Z M8.99366991,4.4 C5.2823276,4.4 1.49366991,6.90316667 1.49366991,9 C1.49366991,11.0572222 5.34727602,13.6 8.99675851,13.6 C12.6454678,13.6 16.4983007,10.9677778 16.4936699,8.99936111 C16.4936699,7.06991667 12.5758802,4.4 8.99366991,4.4 Z M8.99366852,6.49367033 C10.3743793,6.49367033 11.4936685,7.61295846 11.4936685,8.99367033 C11.4936685,10.3743822 10.3743793,11.4936703 8.99366852,11.4936703 C7.61295633,11.4936703 6.49366852,10.3743822 6.49366852,8.99367033 C6.49366852,7.61295846 7.61295633,6.49367033 8.99366852,6.49367033 Z M8.99366782,7.89367033 C8.38615477,7.89367033 7.89366813,8.3861571 7.89366813,8.99367033 C7.89366813,9.60118355 8.38615477,10.0936703 8.99366782,10.0936703 C9.60118088,10.0936703 10.0936675,9.60118355 10.0936675,8.99367033 C10.0936675,8.3861571 9.60118088,7.89367033 8.99366782,7.89367033 Z" fill="currentColor" fill-rule="evenodd" clip-rule="evenodd"></path>
</svg><span class="tw-ml-4 tw-leading-none"><b class="detailmarkettool-browse-num">70</b> people are viewing this right now</span>
</div>
<div class="tw-w-full tw-flex tw-items-center tw-mt-4 product-info__marketing-delivery-time product-info__marketing-delivery-time_date" data-delivery-min="7" data-delivery-max="14" style="display:none">
<svg class=" " xmlns="http://www.w3.org/2000/svg" width="18px" height="18px" viewBox="0 0 18 18"><path d="M9,0 C13.9705627,0 18,4.02943725 18,9 C18,13.9705627 13.9705627,18 9,18 C4.02943725,18 0,13.9705627 0,9 C0,4.02943725 4.02943725,0 9,0 Z M9,1.48235294 C4.84811818,1.48235294 1.48235294,4.84811818 1.48235294,9 C1.48235294,13.1518818 4.84811818,16.5176471 9,16.5176471 C13.1518818,16.5176471 16.5176471,13.1518818 16.5176471,9 C16.5176471,4.84811818 13.1518818,1.48235294 9,1.48235294 Z M8.83954151,5.36631265 C9.24888197,5.36631265 9.58071798,5.69814865 9.58071798,6.10748912 L9.58071798,9.50101853 L12.6099454,11.2505095 C12.9644446,11.4551797 13.085905,11.9084761 12.8812348,12.2629754 C12.6765646,12.6174746 12.2232681,12.738935 11.8687689,12.5342648 L8.56768384,10.6283824 C8.53373785,10.6087837 8.50192872,10.5869052 8.47233818,10.563052 C8.24905128,10.4357423 8.09836504,10.1950954 8.09836504,9.91925382 L8.09836504,6.10748912 C8.09836504,5.69814865 8.43020105,5.36631265 8.83954151,5.36631265 Z" fill="currentColor" fill-rule="evenodd" clip-rule="evenodd"></path>
</svg><span class="tw-ml-4 tw-leading-none">Get it between <b class="7day">Jan 8</b> - <b class="14day">Jan 10</b></span>
</div></div>
<script type="text/javascript">
jQuery(function($){
refresh()
function refresh() {
setTimeout(() => {
$('.detailmarkettool-browse-num').text(randomNum(40, 100))
refresh()
}, randomNum(4000, 8000));
}
refresh_stock()
function refresh_stock() {
setTimeout(() => {
$('.wp_cp_stock').text(randomNum(5, 20))
}, 1000);
}
add_7day_time()
function add_7day_time() {
var dateObj = new Date(new Date().setDate(new Date().getDate() + 3));
var month = dateObj.getUTCMonth(); //months from 1-12
var day = dateObj.getUTCDate();
var m=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Spt","Oct","Nov","Dec");
newdate = m[month] + " " + day;
setTimeout(() => {
$('.7day').text(newdate)
}, 1000);
}
add_14day_time()
function add_14day_time() {
var fourteen_dateObj = new Date(new Date().setDate(new Date().getDate() + 5));
var fourteen_month = fourteen_dateObj.getUTCMonth(); //months from 1-12
var fourteen_day = fourteen_dateObj.getUTCDate();
var m=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Spt","Oct","Nov","Dec");
fourteen_newdate = m[fourteen_month] + " " + fourteen_day;
setTimeout(() => {
$('.14day').text(fourteen_newdate)
}, 1000);
}
function randomNum(min, max) {
return Math.floor(Math.random() * (max - min + 1) + min);
}
})
</script>

浙公网安备 33010602011771号