product

Auto remove Sale product category from not on sale products in Woocommerce

柔情痞子 提交于 2019-12-11 04:09:51
问题 In woocommerce I am using the code from this answer thread that assign a "Sale" product category to a product that is on sale (so with an active sale price) . I have tried to remove "Sale" product category when the product is not on sale anymore without success. Is it possible to automatically remove products from the "Sale" category when they are not anymore on sale? 回答1: The following version code will automatically remove products from the "Sale" category when they are not anymore on sale:

add attribute in product information -> Inventory tab

痞子三分冷 提交于 2019-12-11 04:08:35
问题 Hey, I just realise how easy is to add attributes to the form products in ADMIN, and its working perfectly. So similarly to setting attributes for General, Prices, Meta Information, Images, Recurring Profiles, Design and More Information, how can I add an attribute to Inventory form? Thanks in advance for any help. 回答1: For me (in Magento v 1.3.2.4) creating attributes the usual way (Catalog>Attributes>Manage Attributes) didn’t work in this case, as the value for that attribute didn’t get

Woocommerce: get a list for all sku product

怎甘沉沦 提交于 2019-12-11 03:59:17
问题 I would to get in a <li> list all sku there are in an ecommerce. I belive that I should use foreach cycle, but I don't know how to recall the selection of all products. Thanks for all reply, and sorry for my bad english. Greatings 回答1: Please try this. Let me know if this works perfectly ;) $args = array( 'post_type' => 'product', 'posts_per_page' => -1 ); query_posts( $args ); if( have_posts() ): echo '<ul>'; while ( have_posts() ) : the_post(); echo '<li>'. $product->get_sku() . '</li>';

Set bookable product base cost programatically in Woocommerce Bookings

删除回忆录丶 提交于 2019-12-11 03:56:21
问题 I am trying to calculate the Base cost of a WooCommerce bookable product and managed to get it done using this: function modify_baseprice() { global $post; $productid = $post->ID; $product = new WC_Product($productid); $product_block_price = $product->wc_booking_block_cost; $product->wc_booking_cost = ($product_block_price*0.6) + 100; $pricing_data = update_post_meta( $productid, '_wc_booking_cost', $product->wc_booking_cost); return $pricing_data; } add_action( 'woocommerce_bookings_after

Display Woocommerce notices on a page

半腔热情 提交于 2019-12-11 03:28:26
问题 I have created a function to display some products with a shortcode, but the problem I am having is that the errors messages are not shown on that page. For example if some fields are required then it's only displayed on the cart/checkout page. Here's some of my code: while ( $query->have_posts() ) : $query->the_post(); global $product; ?> <div style="border-bottom:thin dashed black;margin-bottom:15px;"> <h2><?php the_title(); ?> <span><?php echo $product->get_price_html();?></span></h2> <p><

Add the parent product name to each cart item names in WooCommerce

家住魔仙堡 提交于 2019-12-11 03:02:09
问题 I Would like to display the parent product name with child product name (cart item) in cart page, for my grouped products . I am selecting Parent product data as grouped product under linked product -> Grouped products adding child product. The code from template cart.php : echo apply_filters( 'woocommerce_cart_item_name', sprintf( '<a href="%s">%s</a>', esc_url( $product_permalink ), $_product->get_name() ), $cart_item, $cart_item_key ) This is what I would like for each cart item: Parent

Change all product prices from a specific product tag in Woocommerce 3

一笑奈何 提交于 2019-12-11 02:59:07
问题 I used a function to be able to markup all product automatically without having to use SQL or manually do it as they get re-uploaded and updated very frequently. The function works perfectly other than the has_term if statements. They work in the Wordpress backend and apply the pricing rules as soon as I add the tag, but when I try to add the product to cart it reverts back to the original price in the cart and checkout pages. If I remove that if statement it works with no issues. I need a

Catalog Price Rules “Apply Rules” programmatically

偶尔善良 提交于 2019-12-11 02:55:57
问题 I have created one Catalog Price Rule Programmatically it works fine. so my issue is, I need to do login with admin and need click button of "Apply Rules" other wise discount is not apply in magento store, so i need "Apply Rules" programmatically and i have no idea about it how to do. Any help or suggestion will be appreciated. 回答1: You can Apply Rules using the below code with Newly created Catalogrule ID $rule = Mage::getModel('catalogrule/rule')->load($ruleId); Mage::getResourceModel(

Updating product post meta data in admin meta box field

若如初见. 提交于 2019-12-11 02:24:10
问题 I am trying to update WooCommerce product meta data using update_post_meta() function, but it does''t work. Here is my code: function woo_add_deal_general_fields_save( $post_id ){ $post_id = (int)$post_id; // tried to convert into integer $woocommerce_textarea = $_POST['_deal_textarea']; if( !empty( $woocommerce_textarea ) ) if ( get_post_meta($post_id, '_deal_textarea', FALSE ) ) { $test= update_post_meta($post_id, '_deal_textarea', $woocommerce_textarea ); } else { add_post_meta($post_id, '

Filter Woocommerce products based on custom product attribute value

荒凉一梦 提交于 2019-12-11 02:13:28
问题 In Woocommerce, I have a product attribute called restriction_id . I am wanting to filter the products based on certain restriction id's . For example if a value is set to 35 in a php session variable I want to filter out any product that has the attribute for restriction_id set to 35 . What would I put in here? Here is my starting code: // Define the woocommerce_product_query callback function action_woocommerce_product_query( $q, $instance ) { // The code }; // Add the action add_action(