wordpress

WC_Product::get_gallery_attachment_ids is deprecated since version 3.0

房东的猫 提交于 2021-02-10 12:52:26
问题 When define('WP_DEBUG', true); and my php code <div class="col-md-5 col-sm-5 mb-xs-30"><?php // echo single_product_summary_sale_flash();?> <div class="fotorama" data-nav="thumbs" data-allowfullscreen="native"> <a href="#"> <?php the_post_thumbnail(); ?> </a> <?php global $product; $attachment_ids = $product->get_gallery_attachment_ids(); foreach( $attachment_ids as $attachment_id ) { $image_link = wp_get_attachment_url( $attachment_id ); ?> <a href="#"><img src="<?php echo $image_link;?>"

Set specific taxable shipping rate cost to 0 based on cart subtotal in WooCommerce

喜夏-厌秋 提交于 2021-02-10 12:49:28
问题 With following code I'm able for specific shipping rate method (here 'easypack_parcel_machines') to set the cost to 0, when cart subtotal is up to a specific amount (here 150 PLN) : function override_inpost_cost( $rates, $package ) { // Make sure paczkomaty is available if ( isset( $rates['easypack_parcel_machines'] ) ) { // Current value of the shopping cart $cart_subtotal = WC()->cart->subtotal; // Check if the subtotal is greater than 150pln if ( $cart_subtotal >= 150 ) { // Set the cost

Set specific taxable shipping rate cost to 0 based on cart subtotal in WooCommerce

守給你的承諾、 提交于 2021-02-10 12:47:57
问题 With following code I'm able for specific shipping rate method (here 'easypack_parcel_machines') to set the cost to 0, when cart subtotal is up to a specific amount (here 150 PLN) : function override_inpost_cost( $rates, $package ) { // Make sure paczkomaty is available if ( isset( $rates['easypack_parcel_machines'] ) ) { // Current value of the shopping cart $cart_subtotal = WC()->cart->subtotal; // Check if the subtotal is greater than 150pln if ( $cart_subtotal >= 150 ) { // Set the cost

Play Html5 video on scroll

旧时模样 提交于 2021-02-10 11:43:33
问题 I am working on a Wordpress site and I have the code below which is working how I want it (only playing once, with the "replay" button appearing at the end) I would like it to start playing when it is scrolled to ie. in the viewport. I have seen a few different ways of making this happen on here, but I can't get them to play nice with my current code. HTML <div class="spacer"> </div> <div class="video-wrapper"> <video id="bVideo" muted autoplay> <source src="https://www.w3schools.com/html/mov

Http post 常用的四种请求方式

纵饮孤独 提交于 2021-02-10 08:59:08
http1.1协议 规定http 的请求方式有OPTIONS、GET、HEAD、POST、PUT、DELETE、TRACE、CONNECT几种方式。其中POST是一种最常用的向服务器提交数据的方法,本文主要讨论POST提交数据的四种方式。 application/x-www-form-urlencoded 这应该是最常见的 POST 提交数据的方式了。浏览器的原生 <form> 表单,如果不设置 enctype 属性,那么最终就会以 application/x-www-form-urlencoded 方式提交数据。请求类似于下面这样(无关的请求头在本文中都省略掉了): POST http://www.example.com HTTP/1.1 Content-Type: application/x-www-form-urlencoded;charset=utf-8 title=test&sub%5B%5D=1&sub%5B%5D=2&sub%5B%5D=3 首先,Content-Type 被指定为 application/x-www-form-urlencoded;其次,提交的数据按照 key1=val1&key2=val2 的方式进行编码,key 和 val 都进行了 URL 转码。大部分服务端语言都对这种方式有很好的支持。例如 PHP 中,$_POST['title']

How to configure wordpress application with simple php application using Nginx?

五迷三道 提交于 2021-02-10 07:39:09
问题 I want to configure a Wordpress application with a simple php application. The directory structure of the application is as follow : Root directory : /var/www/demoApp/ Wordpress directory : /var/www/demoApp/wordpress/ Here i want to access the wordpress application using route http://BASE_URL/wordpress. But i am not able to configure the web server. All the php pages under /var/www/demoApp/ directory are working fine using url http://BASE_URL/. While wordpress files are not being loaded

WooCommerce: Set country by default in checkout page for unlogged users

浪尽此生 提交于 2021-02-10 07:34:52
问题 How to make the country default for regular (unregistered users). But if the buyer has a personal account and entered the country there, he would not be thrown into default in checkout? I have tried to use WooCommerce: Set country by default in checkout page answer, but it does work for all users logged in and guest… How to set the default country only for unregistered users? 回答1: Use is_user_logged_in() conditional tag as follows: add_filter( 'default_checkout_billing_country', 'change

Wordpress/htaccess - allow access to subdirectory

北慕城南 提交于 2021-02-10 07:34:33
问题 I have a subdirectory ( app ) I want to access that is in the root folder of my wordpress site. I have looked here: https://wordpress.stackexchange.com/questions/20152/cannot-access-non-wordpress-subdirectories-as-wordpress-overrides-them-with-a-40 I have tried the solutions and nothing worked. I also tried adding a separate .htaccess file to the app subdirectory that looks like this: DirectoryIndex index.php index.html index.htm Options +Indexes But it didn't seem to help: The main .htaccess

Adding script, via plugins, in the admin head

僤鯓⒐⒋嵵緔 提交于 2021-02-10 06:49:08
问题 I've made a Wordpress plugin, and I'm trying to add javascript to the admin head. I've tried but couldn't managed to do it, could anyone help? Bellow is what I was going with: function __construct() { add_action('wp_head', 'wpb_hook_javascript'); } function wpb_hook_javascript() { ?> <script> // javscript code </script> <?php } 回答1: You need OOP structured solution which is following. class testing { public function __construct() { add_action( 'admin_head', array($this, 'admin_script'), 10 );

Allow add to cart 3 products max for a specific product category in Woocommerce

|▌冷眼眸甩不掉的悲伤 提交于 2021-02-10 06:41:36
问题 I am trying to send out a maximum of 3 free samples to customers with free shipping. I have created some 0 priced product and set them in "samples" product category. This specific products have option "sold individually" so customers can only have one of each sample. I cannot figure out how to allow only a maximum of 3 samples products from this product category on cart. Any help is appreciated. 回答1: This can be done easily using woocommerce_add_to_cart_validation action hook to limit