product

Getting the value of the product's id value (_product_id) after the payment in WooCommerce

邮差的信 提交于 2019-12-11 06:09:53
问题 I want to get the value of _product_id on the payout page ( thankyou.php ), can somebody help me with this. I have attached an image of the field I need exactly that value 回答1: You can use woocommerce_thankyou hook to get the product ID's in thankyou page function wh_getProductIds($order_id) { //getting order object $order = wc_get_order($order_id); $product_id_arr = []; //getting all line items foreach ($order->get_items() as $item) { $product = $item->get_product(); $product_id_arr =

randomize default products in opencart

Deadly 提交于 2019-12-11 05:45:34
问题 I'm using OpenCart V1.5.3.1 and am trying to randomize or shuffle the products per category on page load. The other sort options should still work though (per price, rating, alphabetical,..). Anybody that can give me some pointers? Many thanks, Steven Code I've tried: In controller/catalog/product/category.php Just below $this->data['products'][] = array( 'product_id' => $result['product_id'], 'thumb' => $image, 'name' => $result['name'], 'description' => utf8_substr(strip_tags(html_entity

Eclipse product: Export multiple versions of a product which has slight variations

冷暖自知 提交于 2019-12-11 05:27:24
问题 This is a relatively open ended question so I wouldn't just mind being pointed in the right direction. I have a product that uses the Eclipse workbench to allow users to program in a custom language. For this product, I will also have some minor UI and internal changes for a lighter version to be exported. For example, a full version of the product contains some extra views and menus, and behaves slightly differently (like when creating a new file) where as the ligher version does not contain

Displaying the 'out of stock' string on shop page but not the stock quantity.

£可爱£侵袭症+ 提交于 2019-12-11 05:26:55
问题 I'm using this piece of code in my functions.php file of my WordPress/WooCommerce site: function envy_stock_catalog() { global $product; if ( $product->is_in_stock() ) { echo $product->get_stock_quantity() ; } else { echo '<div class="out-of-stock" >' . __( 'out of stock', 'envy' ) . '</div>'; add_action('init','remove_loop_button'); } } add_action( 'woocommerce_after_shop_loop_item_title', 'envy_stock_catalog' ); This code displays the 'out of stock' notice on the shop page where all

Show WooCommerce products only to multiple authorized user roles

不问归期 提交于 2019-12-11 05:22:28
问题 I'm trying to adapt "Completely hide products from unauthorized users in WooCommerce" answer code to also allow several custom user roles to view this products. I believe the best way to accomplish this is to expand the authorized user function to include this user roles. This is the changes that I have tried to implement with no success. Can someone shine a light on how to proceed? // Conditional function checking for authorized users function is_authorized_user() { if ( is_user_logged_in()

Add containing <div> inside <li> output from WooCommerce shortcode

我的未来我决定 提交于 2019-12-11 05:11:11
问题 I am looking to use this shortcode: [product_category category="music"] Which outputs this code: <div class="woocommerce columns-4"> <ul class="products"> <li class="post-83 product type-product status-publish has-post-thumbnail product_cat-albums product_cat-music first instock downloadable shipping-taxable purchasable product-type-simple"> <a href="http://localhost/websitename/product/woo-album-1/" class="woocommerce-LoopProduct-link"><img width="300" height="300" src="http://localhost

Change price location on single product pages

隐身守侯 提交于 2019-12-11 04:48:39
问题 This is something that has been doing my head in and I can't seem to find exactly what I want on here. I am trying to move the price on my product pages to display just above or beside the add to cart button. Page link for a product is here I have played around with this before, and managed to create a second price in the position I wanted, but still had the original price at the top and couldn't get rid of it. How can I achieve this? Thanks 回答1: This will work just for simple products as

Convert a Woocommerce hooked function into a shortcode

吃可爱长大的小学妹 提交于 2019-12-11 04:46:31
问题 A previous question of mine was answered and included two separate functions, one using a WooCommerce add_action hook. How can I take this answer and convert it to a shortcode that I could add to a product page? I am using a page builder (Divi Builder) to create a custom layout/template of WooCommerce product pages. Having a shortcode will allow me to paste the shortcode into the builder, and have it output the result anywhere within that template structure. This is the code I need turned

Retrieving the label name for a custom fields in backend product tabs

落爺英雄遲暮 提交于 2019-12-11 04:45:38
问题 Below is the WooCommerce Custom Product with custom field, custom tab and it's content: I'm sampling the first text field at this tab. Goal is to get the "label" property of these fields. function launch_product_tab_content() { global $post; ?><div id='launch_contents' class='panel woocommerce_options_panel'><?php ?><div class='options_group'><?php woocommerce_wp_text_input( array( 'id' => '_text_announced', 'label' => __( 'Announced(Global)', 'woocommerce' ), 'desc_tip' => 'true',

Add sale price programmatically to product variations

荒凉一梦 提交于 2019-12-11 04:28:21
问题 I need to update the sale price programmatically, on variable product and all his variations. What kind of meta field do I need to add? I'm trying to update main product such as: update_post_meta($post_id, '_regular_price', '100'); update_post_meta($post_id, '_price', '50'); update_post_meta($post_id, '_sale_price', '50'); and then I update every single variations update_post_meta($variation_id, '_regular_price', '100'); update_post_meta($variation_id, '_price', '50'); update_post_meta(