10up / distributor

Share content between your websites.
https://distributorplugin.com
GNU General Public License v2.0
628 stars 155 forks source link

Sale Price not pulling for product #1153

Open ScrewlooseA opened 9 months ago

ScrewlooseA commented 9 months ago

Describe the bug

when adding a sale price to the Master shop, the distributed product doesnt get the sale price pushed to it

Steps to Reproduce

https://telechoice.com.au/shop/mobile-phones/oppo-find-x3-neo-5g-256gb/ vs https://shop.screwlooseit.com.au/product/oppo-find-x3-neo-oppo-official-refurbished-dealer/

Screenshots, screen recording, code snippet

No response

Environment information

No response

WordPress information

No response

Code of Conduct

jeffpaul commented 9 months ago

@ScrewlooseA what plugin(s) are you using to manage those storefronts and sale pricing?

ScrewlooseA commented 9 months ago

We are using WooCommerce with elementor.

Get Outlook for Androidhttps://aka.ms/AAb9ysg

Kind regards, General Manager 1300 245 575 @.*** Unless otherwise stated, this email is confidential. If received in error, please delete, and inform the sender by return email. Unauthorized use, copying or distribution is prohibited. Australian Client Services (ABN - 59 160 395 479) and Screwloose WA (ABN – 11 655 843 968) is not responsible for viruses, delays, errors, omissions and/or interceptions in transmission.


From: Jeffrey Paul @.> Sent: Thursday, November 16, 2023 10:06:34 PM To: 10up/distributor @.> Cc: Alex Niazov @.>; Mention @.> Subject: Re: [10up/distributor] Sale Price not pulling for product (Issue #1153)

You don't often get email from @.*** Learn why this is importanthttps://aka.ms/LearnAboutSenderIdentification @ScrewlooseAhttps://github.com/ScrewlooseA what plugin(s) are you using to manage those storefronts and sale pricing?

— Reply to this email directly, view it on GitHubhttps://github.com/10up/distributor/issues/1153#issuecomment-1814499928, or unsubscribehttps://github.com/notifications/unsubscribe-auth/BDEARVGZYT23F7JSQFJ77ZDYEYMWVAVCNFSM6AAAAAA7NVGVNCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMJUGQ4TSOJSHA. You are receiving this because you were mentioned.Message ID: @.***>

aaronware commented 9 months ago

Not sure if this is helpful however if these products are variable we've had to add a lot of customizations to take into account how Woo handles product types and what is publicly accessible. By default, Distributor doesn't handle child post relationships this includes variations of a variable product. Additionally, the "product type" on distribution is being converted from variable to "Simple" the default product type in WooCommerce. Again this is due to how the product type is again a nonpublic taxonomy which Distributor will respect.

I can post some examples of what we are doing later. But to start if you don't want to wait long story short, you'll need to hook into what taxonomy terms that are being distributed and also handle distributing child posts in order to have Variable Products and Group Products to work "As expected"

aaronware commented 9 months ago

@ScrewlooseA Also noticed you mentioned Product type challenge here as well https://github.com/10up/distributor/issues/1142

While I think compatibility is important. I think it's less of a bug and more so a feature to allow more "off the shelf" compatibility through standardized add-ons/extensions. Obviously, it's not my plugin and @jeffpaul can speak to intent, but I think it's less on the Distributor/10up team to handle supporting custom post types and taxonomies directly (from any plugin , site or developer/agency). Especially making any opinion on who/what or how it supports more complex implementations like WooCommerce or WPML for example. (2 plugins our team has needed to adapt to a lot with how distributor works).

It may be more fruitful to potentially determine what hooks/filters are missing in order to accomplish addons/extensions to be able to support more complex use cases. There are numerous issues here related to these same challenges you have even ones I've reported. There are workarounds for sure. Some simple some not so much

aaronware commented 9 months ago

Ok so I looked at @linchpin's implementation with Woo. Your issue is a side effect of how Distributor works. As documented and as I mentioned. Distributor doesn't take into account Post hierarchy and child posts being pushed (you'll need to handle that). You're not getting a price because the price of the product is more than likely set on the Variation level not on the variable product itself. This results in no price. If you tackle sending variations to your distributed sites. The prices will come over by default (We have seen this work in production). I know this because we actually have a policy to not distribute pricing due to business rules and we explicitly use dt_sync_meta to run through an allow/block list.

The work we are doing to sync child posts is pretty complex at this point so I can't share a simple gist to solve your challenge but this is an example of the hooks we are using with some shoves in the right direction. If I get some time I can try to put this into a more consumable repo

While it may not be the answer you are looking for, hopefully it gives you a shove in the right direction. If I get some time I'll try to get a repo going with a real-world example

// Sync Meta
add_action('dt_sync_meta', [$this, 'filter_sync_post_meta'], 10, 4);
add_action('dt_after_set_meta', [$this, 'after_set_meta'], 10, 3);

// Sync Variation Products
add_filter('dt_push_post_args', [$this, 'schedule_variations_push'], 10, 4); // Use Action Scheduler to create an event for each variation of a variable product to sync behind the scenes so the AJAX request to save post doesn't time out in the browser (See similar issues with Media Sync)
add_filter('dt_subscription_post_args', [$this, 'schedule_variations_push'], 10, 2);
add_action('linchpin_dt_sync_variations', [$this, 'push_variations_to_external'], 10, 2); // Use ActionScheduler Events to Push individual variation based on schedule 
add_action('dt_process_distributor_attributes', [$this, 'update_variation_parent_after_push'], 10, 3);
jeffpaul commented 9 months ago

@aaronware that's all super helpful, thank you! If you've got any snippets that would help others using Woo, dropping them into https://10up.github.io/distributor/tutorial-snippets.html would be awesome!