shortcode

Radio buttons for custom post type categories from shortcode comma separated value

帅比萌擦擦* 提交于 2021-01-07 02:59:08
问题 I have created a custom post type. Everything works fine with a shortcode like this [program] Now I would like to be able to create a shortcode like this [program category="category_1,category_2,category_3"] All those categories slugs from the shortcode have to appear in a radio button filter with the categorie name. Its working with only one category in the shortcode but once they're more and with commas it doesn't. <?php function program_shortcode( $atts ) { ob_start(); extract( shortcode

Why does WooCommerce Order Shortcode Generate Plugin Notice on Custom Thank You Page?

微笑、不失礼 提交于 2021-01-05 11:23:46
问题 I have created a re-direct to a custom "Thank You" ( order-received ) page in WooCommerce by using my child theme and functions.php . The re-direct works as intended and all other shortcodes that I have created works fine, except for this. When inserting my [order_cost_breakdown] shortcode using Gutenberg on my Thanks page and when placing on order, I get this notice : Notice: Undefined variable: show_purchase_note in /wp-content/plugins/woocommerce/templates/order/order-details-item.php on

Get WooCommerce Product total sales amount

≡放荡痞女 提交于 2020-12-13 03:30:34
问题 I have created a shortcode that will returns all products in a loop. I am looking for a way to get the total sales for each product. Right now i'm still having hard time finding the solution. This is my code: function loop_ffh_function() { ?> <div class="row"> <?php $args = array( 'numberposts' => -1, 'post_type' => 'product', 'orderby' => 'date'); $loop = new WP_Query($args); while ($loop->have_posts()) : $loop->the_post(); global $product; ?> <?php $productID = get_the_ID(); ?> <div class=

Call to a member function get_items() on boolean in WooCommerce thankyou

谁说胖子不能爱 提交于 2020-11-29 10:28:33
问题 I am trying to get order details to display a summary on my thank you page. The issue I am having is that this code snippet I have is breaking my wordpress. I have the stacktrace but I am unsure on how to fix it. The code to me looks correct so ensure why it's not working. Does anybody have any idea what is the meaning of this stacktrace and how I can fix it? An error of type E_ERROR was caused in line 7 of the file /home4/xxx/public_html/staging/4326/wp-content/plugins/code-snippets/php

Call to a member function get_items() on boolean in WooCommerce thankyou

房东的猫 提交于 2020-11-29 10:27:50
问题 I am trying to get order details to display a summary on my thank you page. The issue I am having is that this code snippet I have is breaking my wordpress. I have the stacktrace but I am unsure on how to fix it. The code to me looks correct so ensure why it's not working. Does anybody have any idea what is the meaning of this stacktrace and how I can fix it? An error of type E_ERROR was caused in line 7 of the file /home4/xxx/public_html/staging/4326/wp-content/plugins/code-snippets/php

Call to a member function get_items() on boolean in WooCommerce thankyou

岁酱吖の 提交于 2020-11-29 10:27:05
问题 I am trying to get order details to display a summary on my thank you page. The issue I am having is that this code snippet I have is breaking my wordpress. I have the stacktrace but I am unsure on how to fix it. The code to me looks correct so ensure why it's not working. Does anybody have any idea what is the meaning of this stacktrace and how I can fix it? An error of type E_ERROR was caused in line 7 of the file /home4/xxx/public_html/staging/4326/wp-content/plugins/code-snippets/php

Get and display the selected variation SKU in WooCommerce

对着背影说爱祢 提交于 2020-07-15 21:55:52
问题 I have this code that works for simple product type but not for variable products in WooCommerce: add_shortcode( 'product_sku_div', 'wc_product_sku_div'); function wc_product_sku_div() { global $product; return sprintf( '<div class="widget" sp-sku="%s"></div>', $product->get_sku() ); } How can I make it work for both simple and variable products? 回答1: You need the Variation ID to get the SKU of Variable Product. If you pass the Variation ID in the below Function, then you can get its SKU.

Get and display the selected variation SKU in WooCommerce

空扰寡人 提交于 2020-07-15 21:55:18
问题 I have this code that works for simple product type but not for variable products in WooCommerce: add_shortcode( 'product_sku_div', 'wc_product_sku_div'); function wc_product_sku_div() { global $product; return sprintf( '<div class="widget" sp-sku="%s"></div>', $product->get_sku() ); } How can I make it work for both simple and variable products? 回答1: You need the Variation ID to get the SKU of Variable Product. If you pass the Variation ID in the below Function, then you can get its SKU.

Get and display the selected variation SKU in WooCommerce

空扰寡人 提交于 2020-07-15 21:51:52
问题 I have this code that works for simple product type but not for variable products in WooCommerce: add_shortcode( 'product_sku_div', 'wc_product_sku_div'); function wc_product_sku_div() { global $product; return sprintf( '<div class="widget" sp-sku="%s"></div>', $product->get_sku() ); } How can I make it work for both simple and variable products? 回答1: You need the Variation ID to get the SKU of Variable Product. If you pass the Variation ID in the below Function, then you can get its SKU.

Get and display the selected variation SKU in WooCommerce

这一生的挚爱 提交于 2020-07-15 21:51:22
问题 I have this code that works for simple product type but not for variable products in WooCommerce: add_shortcode( 'product_sku_div', 'wc_product_sku_div'); function wc_product_sku_div() { global $product; return sprintf( '<div class="widget" sp-sku="%s"></div>', $product->get_sku() ); } How can I make it work for both simple and variable products? 回答1: You need the Variation ID to get the SKU of Variable Product. If you pass the Variation ID in the below Function, then you can get its SKU.