woocommerce-subscriptions

Woocommerce Subscriptions - Get Start date

余生颓废 提交于 2020-01-15 06:51:53
问题 I'm trying to create a function that returns the start date of a users subscription. I'm using woocommerce and the subscriptions plugin. I had this code working, however, it returned a "depreciated" error in my debug.log - and was also VERY slow loading: function subscriber_start_date() { global $current_user; $user = wp_get_current_user(); // Set start date to initial value $start_date = FALSE; // Get ALL subscriptions $subscriptions = WC_Subscriptions_Manager::get_users_subscriptions( $user

Hide “free trial” text from Woocommerce Subscriptions price but keep the Sign-Up Fee

…衆ロ難τιáo~ 提交于 2020-01-05 04:15:12
问题 The first part of the question (Hide the “free trial” text from Woocommerce Subscriptions price) was answered in this awesome post: Hide the "free trial" text from Woocommerce Subscriptions price However, it removed the "and a xx sign-up fee". Is there any way to keep the sign up fee text after removing the free trial text? 回答1: Updated - Try the following: add_filter( 'woocommerce_subscriptions_product_price_string', 'subscriptions_custom_price_string', 20, 3 ); function subscriptions_custom

Add Custom checkout field to Order in WooCommerce

三世轮回 提交于 2020-01-03 03:59:25
问题 The WooCommerce 3.0 update has not been kind to me. I have added a custom required field to checkout for a domain name, and am having trouble figuring out how to get it to save now. This code adds the field properly still: add_action( 'woocommerce_after_order_notes', 'add_domain_checkout_field' ); function add_domain_checkout_field( $checkout ) { echo '<div id="add_domain_checkout_field"><h2>' . __('Domain') . '</h2>'; woocommerce_form_field( 'sitelink_domain', array( 'type' => 'text',

Woocommerce: Adding second email address not working, unless recipient is admin

China☆狼群 提交于 2019-12-31 06:58:07
问题 I have tried several methods to add additional recipients to Woocommerce emails, but it only seems to work on test orders where the primary recipient is the admin. These are the snippets I've tried. If the customer for the order is the admin, the email is sent both addresses. If the order contains a customer email address, it is only send to that email address and not the CC. Here are the code snippets I've tried: add_filter( 'woocommerce_email_recipient_customer_processing_order', 'my_email

Hide the “free trial” text from Woocommerce Subscriptions price

大兔子大兔子 提交于 2019-12-24 07:39:09
问题 I am trying to remove the "with a XX day free trial" from my product, cart and checkout pages. I need to have the feature still work without having to express it in the product details. 回答1: It is possible using the filter hook 'woocommerce_subscriptions_product_price_string' for this hooked function, this way: add_filter( 'woocommerce_subscriptions_product_price_string', 'subscriptions_custom_price_string', 20, 3 ); function subscriptions_custom_price_string( $price_string, $product, $args )

Store custom data using WC_Cart add_to_cart() method in Woocommerce 3

邮差的信 提交于 2019-12-24 03:08:29
问题 I am creating a membership site and totally created static pages for each Membership plans (have only 3 plans). However, I have added products for each plan and when I hit SELECT PLAN button I redirect to some custom form where I ask users range of info we are going to use to fulfil the plan (same as sneakertub.com). I have written code into the PHP page which will handle SUBMIT action of the form. This PHP file, infopage.php , will process POST data I sent via POST call and stores these all

Get Subscription Product author of a Woocommerce subscription

北战南征 提交于 2019-12-24 01:16:30
问题 How can I iterate through all current active woo subscriptions and print the user ID of the user who published the product related to each active subscription (PHP)? I think something like this will give just the subscriptions: $args = array( 'subscriptions_per_page' => -1, 'post_type' => 'shop_subscription', // WC orders post type 'post_status' => 'wc-active' ); $subscriptions = wcs_get_subscriptions( $args ); 回答1: The following code will query all active subscriptions to get the author Id

Passing custom data from cart items to Order meta in Woocommerce 3

六月ゝ 毕业季﹏ 提交于 2019-12-22 00:18:00
问题 I have implemented a custom HTML Form and asking for some data which my customers will pass to place order successfully. Without these details my order has no importance. For HTML form, I am referencing some custom PHP script which is below and which processes POST data from the Form and creates Cart with these data programmatically. Thanks @LoicTheAztec to help me achieve this. The script.php file code: <?php require_once("../wp-load.php"); $customer_name = $_POST["customer_name"]; $customer

WooCommerce Subscriptions - Check if a product is a subscription product

感情迁移 提交于 2019-12-19 10:23:41
问题 I'd like to know how to determine if a given WC_Product object $product is a subscription product or not. 回答1: You can use their helper function which is probably the most complete: if( class_exists( 'WC_Subscriptions_Product' ) && WC_Subscriptions_Product::is_subscription( $product ) ) { return TRUE; } else { return FALSE; } Or you could also use WooCommerce's $product->is_type( $type ) check. 来源: https://stackoverflow.com/questions/41979866/woocommerce-subscriptions-check-if-a-product-is-a

WooCommerce Subscriptions: set subscription trial length per cart item?

谁说胖子不能爱 提交于 2019-12-13 03:36:58
问题 I'm trying to set a subscription trial length dynamically, depending on the combination of product variation and custom field options selected when the product is added to the cart. For one product variation, there's a choice to either pay immediately, or to defer the first payment until the start of the new year. That option is selected via a custom radio button field. For all other product variations, payment is automatically deferred. It's simple enough to set a default trial length for