Connect WordPress WooCommerce orders using Posts to Posts
$15-85 USD / hour
Скасований
Опублікований over 10 years ago
$15-85 USD / hour
I need a custom WooCommerce function that will connect every new WooCommerce order to an associated post type using Scribu's Post to Post plugin. Everything has a well developed API, I just need you to connect the pieces.
Need to know:
- We will be working with three post types: shop_order, product and campaign
- We will be using two WordPress plugins: WooCommerce and Posts to Posts
- You will be required to work from our test site.
- Please make complete inline comments about what is going on.
- This may not be a complete work order, issues may arise once development starts.
- We will give you extra money to use GitHub. They have great free software.
- We pay in milestones for every couple of hours. We want to ensure that you are on track and
that this project is still a good fit for you.
- We expect you to use Freelancer's visual tracker.
- We give bonuses for high quality work.
Steps:
1) Once a user completes checkout, link their new order with the associated campaigns. The associated campaign is found by calling a function for each product sold that returns the WordPress post id of the campaign associated to the product.
For example say order 301 has two products, A & B. Product A is associated with campaign 1 and product B is associated with campaign 2. So order 301 is to be associated with campaigns 1 & 2.
Use WooCommerce action hook "woocommerce_checkout_order_processed" for this. This snippet may help you get setup: [login to view URL]
2) Once an order is associated with the campaigns of the products purchased create a post meta entry for the order using key "campaign_$pid", where $pid is the post id of the campaign.
The value should be an array of two items counting only products sold relating to that particular campaign:
- value of subtotal (without tax)
- count of products sold
Creating Post to Post connections programmatically...
[login to view URL]
p2p_type( 'YOUR_CONNECTION_TYPE' )->connect( $from_id, $to_id, array(
'date' => current_time('mysql')
) );