wordpress

Need Help in Some Custom Modification to single.php in a WordPress theme

霸气de小男生 提交于 2021-02-17 02:45:11
问题 I am using Custom Field Plugin Pro. I created 3 Fields and 4 Sub Fields of that. Now when I am trying to add the code in single.php WordPress theme editor, then it breaking posts page CSS. After figuring things I found that: when I post the PHP code of just 1 field code then the website doesn't break. But putting 2/3 breaking the website. Also, I found when I put 1-1 entry in each fields then the website works fine with all 3 fields code. I don't know why this is happening. This is the code I

Prevent add to cart if cart contains a specific category (WooCommerce)

限于喜欢 提交于 2021-02-16 21:24:46
问题 I have a store containing 5 categories. It's multivendor and due to shipping complications, I can only sell products from one specific category ('paint') when they are alone in the cart. So I need to prevent add to cart of any non-paint products when the cart contains paint, and display an error message, and I need to prevent paint products being added to a cart containing any other categories, and disaply an error message. I've tried to cobble together this code from snippets I've found

Conditionally hide Woocommerce checkout custom field based on free shipping

只谈情不闲聊 提交于 2021-02-16 20:19:30
问题 In WooCommerce, I am trying to hide one custom added field whenever "free delivery" is selected (automatic selection, based on order amount). I was thinking that I found a solution with code below, but when I load a page on new (incognito) browser window, the field is present and if refresh it, the field is hidden again. // Hide address field, when Free Shipping mode is selected add_filter('woocommerce_checkout_fields', 'xa_remove_billing_checkout_fields'); function xa_remove_billing_checkout

Hide a variation attribute value in Woocommerce variable product dropdown

泪湿孤枕 提交于 2021-02-16 20:14:34
问题 I want to hide specific variations from being shown in the dropdown of woocommerce product pages. I was able to hide the "choose an option" but I am struggling with doing the same for the value="2,5 kg" for example This is my code for hiding "choose an option": add_filter( 'woocommerce_dropdown_variation_attribute_options_html', 'remove_choose_an_option'); function remove_choose_an_option( $html ){ $html = str_replace('<option value="">' . __( 'Choose an option', 'woocommerce' ) . '</option>'

Disable add to cart button based on WooCommerce product custom stock status

假如想象 提交于 2021-02-16 20:00:11
问题 Currently in woocommerce, add to cart button disabled, if the stock status is out of stock . I add new stock status with the label Discontinued product by using woocommerce_product_stock_status_options , now I am looking for a way to treat this product like it is out of stock. Since I believe it is better to separate between a product that is not produced anymore and a product that produced and available in another store but it's not in stock. 回答1: You can use the following to disable add to

java超大文件上传

倾然丶 夕夏残阳落幕 提交于 2021-02-16 17:20:18
上周遇到这样一个问题,客户上传高清视频(1G以上)的时候上传失败。 一开始以为是session过期或者文件大小受系统限制,导致的错误。 查看了系统的配置文件没有看到文件大小限制, web.xml中seesiontimeout是30,我把它改成了120。 但还是不行,有时候10分钟就崩了。 同事说,可能是客户这里服务器网络波动导致网络连接断开,我觉得有点道理。 但是我在本地测试的时候发觉上传也失败,网络原因排除。 看了日志,错误为: java.lang.OutOfMemoryError Java heap space 上传文件代码如下: public static String uploadSingleFile(String path,MultipartFile file) { if (!file.isEmpty()) { byte[] bytes; try { bytes = file.getBytes(); // Create the file on server File serverFile = createServerFile(path,file.getOriginalFilename()); BufferedOutputStream stream = new BufferedOutputStream( new FileOutputStream(serverFile));

Php post not getting the html input element value which append by jquery

三世轮回 提交于 2021-02-16 15:17:37
问题 I have page which user can add date range from, to and price. By default there is three, but user can add more ranges using the add date range button button. My problem is, after adding a few extra date ranges when I get the $_POST value it is not showing the appended html element's post values. javascript part var n = 0; $(document).ready(function () { $("#btn2").click(function () { $("#add_drange").append(" <p><input type='text' name='from" + n + "' class='datepicker' placeholder='From' /> 

Php post not getting the html input element value which append by jquery

人盡茶涼 提交于 2021-02-16 15:16:41
问题 I have page which user can add date range from, to and price. By default there is three, but user can add more ranges using the add date range button button. My problem is, after adding a few extra date ranges when I get the $_POST value it is not showing the appended html element's post values. javascript part var n = 0; $(document).ready(function () { $("#btn2").click(function () { $("#add_drange").append(" <p><input type='text' name='from" + n + "' class='datepicker' placeholder='From' /> 

Add custom tax value at woocommerce checkout

情到浓时终转凉″ 提交于 2021-02-16 14:35:12
问题 I want to add custom % value at woocommerce checkout page, but I want to show it only for Swiss country and hide it for others. Now I have the right code working for that, but the problems is that Im not able to show it when user choose switzerland. Here is a code so please help me see what Im doing wrong here //Add tax for CH country add_action( 'woocommerce_cart_calculate_fees','woocommerce_custom_surcharge' ); function woocommerce_custom_surcharge() { global $woocommerce; if ( WC()-

custom add to cart redirection for a defined product category in WooCommerce 3

ε祈祈猫儿з 提交于 2021-02-16 14:13:34
问题 On a WooCommerce website I would like to be redirect customers on checkout page just after a product is added to cart. However we want it to be for that specific product category instead of all the add to cart buttons. I have tried to look up past solutions but they either just crash my site when I update the functions.php or they are outdated and don't work anymore. I really appreciate any help. 回答1: Updated: Add to cart redirection will not work with ajax add to cart on shop and archives