somewherewarm / woocommerce-subscribe-all-the-things

Experimental mini-extension for WooCommerce Subscriptions that explored the possibility of adding subscription plans to non-subscription product types. Now available on WooCommerce.com as "All Products For WooCommerce Subscriptions".
https://woocommerce.com/products/all-products-for-woocommerce-subscriptions/?aff=46147&cid=5699243
151 stars 50 forks source link

Subscription duration after price outputting twice in cart total #101

Closed ghost closed 7 years ago

ghost commented 7 years ago
screen shot 2017-02-23 at 1 17 14 pm
javorszky commented 7 years ago

Is that working with one copy of STATT running on the site and default theme / no other plugins besides WooCommerce and Subscriptions?

ghost commented 7 years ago

@javorszky

Nope.

WordPress Environment

Home URL: http://adinfern.staging.wpengine.com Site URL: http://adinfern.staging.wpengine.com WC Version: 2.6.14 Log Directory Writable: ✔ WP Version: 4.7.2 WP Multisite: – WP Memory Limit: 1 GB WP Debug Mode: – WP Cron: ✔ Language: en_AU

Server Environment

Server Info: Apache PHP Version: 7.0.13-0ubuntu0.16.04.1 PHP Post Max Size: 100 MB PHP Time Limit: 3600 PHP Max Input Vars: 3000 cURL Version: 7.47.0 OpenSSL/1.0.2g

SUHOSIN Installed: – MySQL Version: 5.7.17 Max Upload Size: 50 MB Default Timezone is UTC: ✔ fsockopen/cURL: ✔ SoapClient: ✔ DOMDocument: ✔ GZip: ✔ Multibyte String: ✔ Remote Post: ✔ Remote Get: ✔ WCS_DEBUG: ✔ No Subscriptions Mode: ❌ Staging

Database

WC Database Version: 2.6.14 : woocommerce_sessions: ✔ woocommerce_api_keys: ✔ woocommerce_attribute_taxonomies: ✔ woocommerce_downloadable_product_permissions: ✔ woocommerce_order_items: ✔ woocommerce_order_itemmeta: ✔ woocommerce_tax_rates: ✔ woocommerce_tax_rate_locations: ✔ woocommerce_shipping_zones: ✔ woocommerce_shipping_zone_locations: ✔ woocommerce_shipping_zone_methods: ✔ woocommerce_payment_tokens: ✔ woocommerce_payment_tokenmeta: ✔

Active Plugins (71)

ManageWP - Worker: by ManageWP – 4.2.16 Gravity Forms: by rocketgenius – 2.1.3 Akismet Anti-Spam: by Automattic – 3.3 Beaver Builder Plugin (Lite Version): by The Beaver Builder Team – 1.9.4 Disable Comments: by Samir Shah – 1.6 Easy Theme and Plugin Upgrades: by Chris Jean – 2.0.0 Google Analytics for WordPress by MonsterInsights: by MonsterInsights – 6.0.4 GPL Kit: by GPL Kit – 1.0.6 Gravity Forms MailChimp Add-On: by rocketgenius – 4.1 Homepage Control: by WooThemes – 2.0.2 Jetpack by WordPress.com: by Automattic – 4.6 MailChimp: by MailChimp – 1.5.7 Nav Menu Roles: by Kathy Darling – 1.8.6 Our Team: by WooThemes – 1.4.1 Regenerate Thumbnails: by Alex Mills (Viper007Bond) – 2.2.6 Say What? Pro: by Lee Willis – 2.0.1 SendGrid: by SendGrid – 1.10.7 Storefront Blog Customiser: by WooThemes – 1.2.1 Storefront Footer Bar: by WooThemes – 1.0.3 Storefront Hamburger Menu: by WooThemes – 1.2.0 Storefront Homepage Contact Section: by WooThemes – 1.0.2 Storefront Homepage Extra Sections: by WPDevHQ – 1.0.2 Storefront Mega Menus: by WooThemes – 1.4.0 Storefront Parallax Hero: by WooThemes – 1.5.4 Storefront Powerpack: by WooThemes – 1.3.1 Storefront Pricing Tables: by WooThemes – 1.0.3 Storefront Product Hero: by WooThemes – 1.2.7 Storefront Product Sharing: by WooThemes – 1.0.3 Storefront Sticky Add to Cart: by WooThemes – 1.1.4 Title Toggle for Storefront Theme: by Wooassist – 1.2.2 Stream: by XWP – 3.1.1 Testimonials: by WooThemes – 1.5.4 Use Any Font: by Dinesh Karki – 4.6 Video User Manuals: by Video User Manuals Pty Ltd – 2.5.4 WooCommerce Accepted Payment Methods: by jameskoster – 0.7.0 WooCommerce Advanced Notifications: by WooThemes – 1.2.2 – 1.2.3 is available WooCommerce Bulk Stock Management: by Automattic – 2.2.3 WooCommerce Cart Notices: by WooThemes / SkyVerge – 1.6.1 WooCommerce Checkout Field Editor: by WooThemes – 1.5.1 – 1.5.3 is available WooCommerce Coupon Campaigns & Tracking: by WooThemes – 1.0.3 WooCommerce Customer/Order/Coupon CSV Import Suite: by WooThemes / SkyVerge – 3.2.1 – 3.2.2 is available WooCommerce Print Invoice & Delivery Note: by Triggvy Gunderson – 4.1.5 WooCommerce Dynamic Pricing: by Lucas Stark – 2.12.2 WooCommerce Email Customizer: by WooThemes – 1.1.5 WooCommerce Extra Product Sorting Options: by SkyVerge – 2.5.0 WooCommerce NAB Transact (Direct Post) Gateway: by Tyson Armstrong – 1.6.0 WooCommerce Google Analytics Integration: by WooThemes – 1.4.0 WooCommerce Memberships: by WooThemes / SkyVerge – 1.7.5 WooCommerce Min/Max Quantities: by WooCommerce – 2.3.15 WooCommerce Mix and Match: Min/Max Quantities: by Kathy Darling – 1.0.3 WooCommerce Mix and Match: by WooThemes – 1.1.8 WooCommerce Product Add-ons: by Automattic – 2.7.26 WooCommerce Product Bundles: by WooThemes – 5.1.1 WooCommerce Product CSV Import Suite: by Automattic – 1.10.12 WooCommerce Product Enquiry Form: by WooThemes – 1.2.1 WooCommerce Product Search: by itthinx – 1.8.1 WooCommerce Sale Flash Pro: by WooThemes – 1.2.5 WooCommerce Sequential Order Numbers Pro: by WooThemes / SkyVerge – 1.10.1 WooCommerce Local Pickup Plus: by WooThemes / SkyVerge – 1.13.5 WooCommerce Smart Coupons: by StoreApps – 3.2 WooCommerce Subscribe All the Things: by Prospress Inc. – 1.1.2 WooCommerce Subscriptions: by Prospress Inc. – 2.1.3 WooCommerce Tab Manager: by WooThemes / SkyVerge – 1.7.4 WooCommerce Table Rate Shipping: by Automattic – 3.0.2 WooCommerce URL Coupons: by WooThemes / SkyVerge – 2.4.1 WooCommerce: by WooThemes – 2.6.14 WooSidebars: by WooThemes – 1.4.3 Yoast SEO Premium: by Team Yoast – 4.3.2 Yoast SEO: Local: by Team Yoast and Arjan Snaterse – 4.3 Yoast SEO: News: by Team Yoast – 4.3 Yoast SEO: WooCommerce: by Team Yoast – 4.3

Settings

Force SSL: ✔ Currency: AUD ($) Currency Position: left Thousand Separator: , Decimal Separator: . Number of Decimals: 2

API

API Enabled: ✔

WC Pages

Shop Base: #4 - /margaret-river-wines/ Basket: #7 - /cart/ Checkout: #8 - /checkout/ My Account: #10 - /my-account/

Taxonomies

Product Types: booking (booking) bundle (bundle) external (external) grouped (grouped) mix and match (mix-and-match) simple (simple) subscription (subscription) variable (variable) variable subscription (variable-subscription)

Theme

Name: Adinfern Child Theme Version: – 0 is available Author URL: Child Theme: ✔ Parent Theme Name: Storefront Parent Theme Version: 2.1.8 Parent Theme Author URL: https://woocommerce.com/ WooCommerce Support: ✔

Templates

Overrides: –

javorszky commented 7 years ago

Can you try it with a default theme and only the necessary plugins? Otherwise my suspicion is that it's the theme / some other plugin doing it.

seb86 commented 7 years ago

I came across this issue when working on a Mix and Match product to support sync. Did not have an issue for a simple or variable product. Nothing to do with the theme as far as I could tell as I tried a few.

ghost commented 7 years ago

Same issue. Twenty Seventeen, Woo, Subscriptions, SATT, Mix and Match active.

screen shot 2017-02-23 at 1 38 54 pm
javorszky commented 7 years ago

If you turn off mix and match, does the issue go away?

ghost commented 7 years ago

Yes

javorszky commented 7 years ago

Reproduced. Issue happening when a mix and match item is in the cart. The duplicate recurrence string shows up because of https://github.com/Prospress/woocommerce-subscribe-all-the-things/blob/master/includes/class-wcsatt-integrations.php#L62.

If that is not there, the subtotal string is not duplicated.

javorszky commented 7 years ago

And that's because we're running $10 / every 6 months through the WC_Subscriptions_Cart::get_formatted_product_subtotal method.

It's a filter-on-a-filter problem, and I can't decide whether it's actually a Subscriptions bug wherein it doesn't take into account that $product_subtotal might already be something we need, or a STATT bug where it shouldn't call the cart method again on the same filter.

$product_subtotal = WC_Subscriptions_Product::get_price_string( $product, array(
    'price'           => $product_subtotal,
    'sign_up_fee'     => $sign_up_fee_string,
    'tax_calculation' => WC()->cart->tax_display_cart,
    )
);

That is in WC_Subscriptions_Cart::get_formatted_product_subtotal(), which is attached to the woocommerce_cart_product_subtotal filter.

That turns WooCommerce's $10 into $10 every 3 months or something similar. However when you add a second function to the same filter, the value passed to the 2nd function isn't going to be $10, it's going to be the value returned by the first method; in this case $10 every 3 months.

The third time we'd this method to the same filter, it would end up being $10 every 3 months every 3 months every 3 months.

@franticpsyx and @thenbrent will be a lot smarter. :)

ghost commented 7 years ago

If I remove this: https://github.com/Prospress/woocommerce-subscribe-all-the-things/blob/master/includes/class-wcsatt-integrations.php#L62.

Will solve the issue for now, or cause more issues?

javorszky commented 7 years ago

It's a bad practice to modify plugin files directly. What you could do is unhook that method in your own plugin with

remove_filter( 'woocommerce_cart_item_subtotal', array( 'WCS_ATT_Integrations', 'show_ppp_bundle_subtotal_details' ), 1000, 3 );

That should work, though I haven't tested it.

If you're using any of the other 2 plugins (Bundles, Composite products), then it might introduce complications. I'm not entirely familiar as to why this is needed in the first place, so I can't give you a 100% accurate answer.

ghost commented 7 years ago

No worries Jav. I'll give it a go.

javorszky commented 7 years ago

That's fine. May I ask you not to abbreviate my username as it's my actual family name?

manospsyx commented 7 years ago

Closing in favour of #127