当用户在我的 woocommerce 商店结帐时,如果他们选择某个支付网关,例如“paypal_pro”、“check”、“bacs”或在我的情况下是“wdc_woo_credits”,我想将税设置为 0。这是一个 woocredits 插件,允许用户使用信用而不是信用卡付款。
我知道这个函数正确地设置了税,因为当我 print_r($cart_object) 我看到我将所有的税设置为 0,但结帐仍然应用了总数中的税。
我想我需要一个在使用下面的函数设置后重新计算税收的函数。
add_action( 'woocommerce_cart_calculate_fees','shipping_method_discount', 20, 1 );
function shipping_method_discount( $cart_object ) {
if ( is_admin() && ! defined( 'DOING_AJAX' ) ) return;
$chosen_payment_method = WC()->session->get('chosen_payment_method');
//if( $chosen_payment_method == 'cheque' ){
if( $chosen_payment_method == 'wdc_woo_credits' ){
$cart_object->set_cart_contents_taxes(0);
$cart_object->set_cart_contents_tax(0);
$cart_object->set_subtotal_tax(0);
$cart_object->set_shipping_tax(0);
$cart_object->set_total_tax(0);
$cart_object->set_fee_tax(0);
$cart_object->set_fee_taxes(0);
$cart_object->set_subtotal_tax(0);
foreach($cart_object->cart_contents as $product){
$cart_object->cart_contents[$product['key']]['line_tax'] = 0;
$cart_object->cart_contents[$product['key']]['line_subtotal_tax'] = 0;
$cart_object->cart_contents[$product['key']]['line_tax_data']['subtotal'] = 0;
$cart_object->cart_contents[$product['key']]['line_tax_data']['total'] = 0;
}
}
//echo '<pre>'; print_r($cart_object); echo '</pre>';
}
Run Code Online (Sandbox Code Playgroud)
此功能检测他们选择的付款选择并重新运行更新结帐功能。但税收仍然在总数中。
add_action( 'woocommerce_review_order_before_payment', 'refresh_payment_methods' ); …Run Code Online (Sandbox Code Playgroud) 检查用户是否已登录的最安全方法是什么?我正在使用php的框架,codeigniter.
$loggedIn = $this->session->userdata('is_logged_in'); // returns 1
if($loggedIn == true): ?>
// do something
<?php endif; ?>
Run Code Online (Sandbox Code Playgroud)
此代码是在控制器中还是在视图中是否重要?
我目前在用nl2br()格式化的数据库中有很多笑话,这会产生...
This is just dummy text. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
<br /><br />
Vestibulum gravida justo in arcu mattis lacinia. Mauris aliquet mi quis diam euismod blandit ultricies ac lacus.
<br /><br />
Aliquam erat volutpat. Donec sed nisi ac velit viverra hendrerit.
<br />
Praesent molestie augue ligula, quis accumsan libero.
Run Code Online (Sandbox Code Playgroud)
我需要一个php函数,而不是转换<br /><br />为a <p></p>,如果只有1个,<br />那就别管它了。还修剪任何空格
因此最终结果将是...
<p>This is just dummy text. Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p> …Run Code Online (Sandbox Code Playgroud) 我对 vue.js 2 有 2 个问题,这里有一个小提琴:https ://jsfiddle.net/tmun9cxa/1/
当您单击列标题时,为什么我的排序不起作用?解决办法是什么?
如何使搜索输入字段仅搜索 pn 列?
我发现的许多示例都使用 vue1 并且已经过时。
<input type="text" value="" v-model="search" placeholder="Search">
<table style="text-align: center;">
<thead>
<tr>
<th v-for="column in columns">
<a
href="#"
v-on:click="sort(column.shortcode)">{{column.label}}
</a>
</th>
</tr>
</thead>
<tbody>
<tr v-for="(product) in products">
<td>{{product.pn}}</td>
<td>{{product.od}}</td>
<td>{{product.id}}</td>
<td>{{product.thickness}}</td>
<td>{{product.lo}}</td>
<td>{{product.weight}}</td>
</tr>
</tbody>
</table>
Run Code Online (Sandbox Code Playgroud)
javascript在这里
var vm = new Vue({
el: '#app',
data: {
currentSort: 'pn',
currentSortDir: 'asc',
search: '',
columns: [
{ label: 'P/N', shortcode: 'pn' },
{ label: 'OD (De,mm)', shortcode: 'od' …Run Code Online (Sandbox Code Playgroud) 我正在尝试检测当前页面是否是我全新安装的WordPress中的主页.
下面的代码片段在page.php中工作,但它在functions.php中不起作用.如何在WordPress中的functions.php中检测主页?
if (is_front_page()) {
echo 'test';
}
Run Code Online (Sandbox Code Playgroud)
我知道我可以使用$_SERVER['REQUEST_URI'],但我认为应该有更好的方法来做到这一点.
在wordpress设置>阅读中,我的主页有一个静态页面.is_home()在我的page.php中不起作用,但is_front_page()在我的page.php中起作用.这两个函数在我的functions.php中都不起作用
当用户从下拉菜单中选择一个值时,我想更改表值。默认情况下,这些值采用公制。如果用户选择标准,那么我想对每个值运行一些数学运算并将指标转换为标准。也能够切换回公制。
https://jsfiddle.net/tmun9cxa/13/
html
<div class="form-filter">
<select name="type" v-model="filter_unit" v-on:change="onSelectUnitChange">
<option value="metric">Metric</option>
<option value="standard">Standard</option>
</select>
</div><!-- /filter -->
<table style="text-align: center;">
<thead>
<tr>
<th v-for="column in columns">
<a
href="#"
v-on:click="sort(column.shortcode)">{{column.label}}
</a>
</th>
</tr>
</thead>
<tbody>
<tr v-for="(product) in showProducts">
<td>{{product.pn}}</td>
<td>{{product.od}}</td>
<td>{{product.id}}</td>
<td>{{product.thickness}}</td>
<td>{{product.lo}}</td>
<td>{{product.weight}}</td>
</tr>
</tbody>
</table>
</div><!-- /app -->
Run Code Online (Sandbox Code Playgroud)
Javascript
var vm = new Vue({
el: '#app',
data: {
currentSort: 'pn',
currentSortDir: 'asc',
category: 'all',
filter_unit: 'metric',
search: '',
columns: [
{ label: 'P/N', shortcode: 'pn' },
{ label: …Run Code Online (Sandbox Code Playgroud) 当我使用 DateTime->modify() 时,它不会保留我的时间。不支持时间吗?我怎样才能拿回我的时间?
我使用的时间:2020-10-31T18:30
我得到的时间:2020-10-31 00:00
我想要的:2020-10-31 18:30
$user_inputed_date = date('Y-m-d g:ia');
$users_inputed_time = strtotime($user_inputed_date);
$date_ymd = date('Y-m-d', $users_inputed_time);
$date_time = date('H:i', $users_inputed_time);
$date = $date_ymd.'T'.$date_time; // 2020-10-31T18:30
// we have this 24 hour format time 2020-10-31T18:30
$dateTime = new DateTime($date);
// get next wednesday
$dateTime->modify('wednesday');
// this returns 2020-10-31 00:00. why did it lose the time?
echo $dateTime->format('Y-m-d H:i');
Run Code Online (Sandbox Code Playgroud) php ×4
vue.js ×2
vuejs2 ×2
wordpress ×2
codeigniter ×1
date ×1
datetime ×1
nl2br ×1
security ×1
woocommerce ×1