Skip to content

Commit

Permalink
fix: spliting order via rest api
Browse files Browse the repository at this point in the history
  • Loading branch information
sabbir1991 committed Jun 25, 2018
1 parent 1b23ea8 commit 8c2af82
Show file tree
Hide file tree
Showing 9 changed files with 997 additions and 408 deletions.
8 changes: 4 additions & 4 deletions assets/js/vue-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -1041,7 +1041,7 @@ let Modal = dokan_get_lib('Modal');
"title": this.__("24/7 super fast premium customer support for you", "dokan-lite"),
"thumbnail": dokan.urls.assetsUrl + '/images/premium/[email protected]'
}, {
"title": this.__("Add Social profile to your vendor’s store and support for store seo", "dokan-lite"),
"title": this.__("Add Social profile to your vendor’s store and support for store SEO", "dokan-lite"),
"thumbnail": dokan.urls.assetsUrl + '/images/premium/[email protected]'
}],

Expand Down Expand Up @@ -3846,7 +3846,7 @@ var staticRenderFns = [
]),
_vm._v(" "),
_c("div", { staticClass: "price" }, [
_c("span", [_c("sup", [_vm._v("$")]), _vm._v("149")]),
_c("span", [_c("sup", [_vm._v("$")]), _vm._v("249")]),
_vm._v(" "),
_c("span", [_vm._v("/year")])
])
Expand All @@ -3856,7 +3856,7 @@ var staticRenderFns = [
_c("div", { staticClass: "plan-name business" }, [_vm._v("Business")]),
_vm._v(" "),
_c("div", { staticClass: "price" }, [
_c("span", [_c("sup", [_vm._v("$")]), _vm._v("149")]),
_c("span", [_c("sup", [_vm._v("$")]), _vm._v("499")]),
_vm._v(" "),
_c("span", [_vm._v("/year")])
])
Expand All @@ -3868,7 +3868,7 @@ var staticRenderFns = [
]),
_vm._v(" "),
_c("div", { staticClass: "price" }, [
_c("span", [_c("sup", [_vm._v("$")]), _vm._v("149")]),
_c("span", [_c("sup", [_vm._v("$")]), _vm._v("999")]),
_vm._v(" "),
_c("span", [_vm._v("/year")])
])
Expand Down
36 changes: 35 additions & 1 deletion includes/api/class-order-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ class Dokan_REST_Order_Controller extends Dokan_REST_Controller{
*/
public function __construct() {
$this->post_status = array_keys( wc_get_order_statuses() );

add_filter( 'woocommerce_new_order_data', array( $this, 'set_order_vendor_id' ) );
add_action( 'woocommerce_rest_insert_shop_order_object', array( $this, 'after_order_create' ), 10, 2 );
}

/**
Expand Down Expand Up @@ -199,7 +202,6 @@ public function validation_before_update_item( $request ) {
return true;
}


/**
* Get formatted item data.
*
Expand Down Expand Up @@ -705,4 +707,36 @@ public function update_order_permissions_check() {
public function check_orders_summary_permissions() {
return current_user_can( 'dokan_view_order_report' );
}

/**
* Set vendor ID on order when creating from REST API
*
* @since 2.8.2
*
* @param array $args
*
* @return array
*/
public function set_order_vendor_id( $args ) {

if ( defined( 'REST_REQUEST' ) ) {
$args['post_author'] = dokan_get_current_user_id();
}

return $args;
}

/**
* Insert into Dokan sync table once an order is created via API
*
* @since 2.8.2 [<description>]
*
* @param WC_Order $object
* @param WP_REST_Request $request
*
* @return void
*/
public function after_order_create( $object, $request ) {
dokan()->orders->maybe_split_orders( $object->get_id() );
}
}
2 changes: 1 addition & 1 deletion includes/api/class-store-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ public function get_total_review_count( $id, $post_type, $status ) {
public function prepare_item_for_response( $store, $request, $additional_fields = [] ) {

$data = $store->to_array();
$data = array_merge( $data, $additional_fields );
$data = array_merge( $data, apply_filters( 'dokan_rest_store_additional_fields', $additional_fields, $store, $request ) );
$response = rest_ensure_response( $data );
$response->add_links( $this->prepare_links( $data, $request ) );
return $response;
Expand Down
2 changes: 1 addition & 1 deletion includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -1812,7 +1812,7 @@ function dokan_wc_email_recipient_add_seller( $email, $order ) {
$sellers = dokan_get_seller_id_by_order( dokan_get_prop( $order, 'id' ) );

//if more than 1 seller
if ( count( $sellers ) > 1 ) {
if ( is_array( $sellers ) && count( $sellers ) > 1 ) {
foreach ( $sellers as $seller_id ) {
$seller = get_userdata( $seller_id );
$seller_email = $seller->user_email;
Expand Down
89 changes: 89 additions & 0 deletions languages/dokan-lite.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<?php
return [
__( 'Select Color', 'dokan-lite' ),
__( 'Clear', 'dokan-lite' ),
__( 'Close', 'dokan-lite' ),
__( 'Active', 'dokan-lite' ),
__( 'Select', 'dokan-lite' ),
__( 'Close modal panel', 'dokan-lite' ),
__( 'Select an image', 'dokan-lite' ),
__( 'Please select an image,', 'dokan-lite' ),
__( 'Dashboard', 'dokan-lite' ),
__( 'net sales this month', 'dokan-lite' ),
__( 'commission earned', 'dokan-lite' ),
__( '%s Vendor', 'dokan-lite' ),
__( 'signup this month', 'dokan-lite' ),
__( 'awaiting approval', 'dokan-lite' ),
__( '%s Products', 'dokan-lite' ),
__( 'created this month', 'dokan-lite' ),
__( '%s Withdrawals', 'dokan-lite' ),
__( 'Stay up-to-date', 'dokan-lite' ),
__( 'We\'re constantly developing new features, stay up-to-date by subscribing to our newsletter.', 'dokan-lite' ),
__( 'Subscribe', 'dokan-lite' ),
__( 'Thank you for subscribing!', 'dokan-lite' ),
__( 'Help', 'dokan-lite' ),
__( 'Upgrade to Dokan Pro!', 'dokan-lite' ),
__( 'Seems To Be Convinced, You Need More Out Of Your Marketplace', 'dokan-lite' ),
__( 'Why Upgrade', 'dokan-lite' ),
__( 'And Many More', 'dokan-lite' ),
__( 'Comparison With Dokan PRO', 'dokan-lite' ),
__( 'The Packages We Provide', 'dokan-lite' ),
__( 'Buy Now', 'dokan-lite' ),
__( '14 Days Money Back Guarantee', 'dokan-lite' ),
__( 'After successful purchase, you will be eligible for conditional refund', 'dokan-lite' ),
__( 'Terms & Condition Applied', 'dokan-lite' ),
__( 'Payment Options:', 'dokan-lite' ),
__( 'People We Have Helped', 'dokan-lite' ),
__( 'Convinced?', 'dokan-lite' ),
__( 'With all the advance features you get it’s hard to resist buying Dokan Pro.', 'dokan-lite' ),
__( 'I Want To Buy Now', 'dokan-lite' ),
__( 'Premium modules to make everything easier & better', 'dokan-lite' ),
__( 'Frontend dashboard for vendors with advanced controls', 'dokan-lite' ),
__( 'Unlimited Product Variations and group product upload', 'dokan-lite' ),
__( 'Zone wise shipping with multiple method for vendors', 'dokan-lite' ),
__( 'Store support based on ticket system for your customers', 'dokan-lite' ),
__( 'Vendors will be able to generate coupon codes', 'dokan-lite' ),
__( 'Earning, Selling and Commission Reports & Statement', 'dokan-lite' ),
__( '24/7 super fast premium customer support for you', 'dokan-lite' ),
__( 'Add Social profile to your vendor’s store and support for store seo', 'dokan-lite' ),
__( 'Frontend order management', 'dokan-lite' ),
__( 'Seller Statement Reports', 'dokan-lite' ),
__( 'Making Announcements', 'dokan-lite' ),
__( 'Customized Product Categories', 'dokan-lite' ),
__( 'Store SEO', 'dokan-lite' ),
__( 'Back Ordering System', 'dokan-lite' ),
__( 'Store Contact Form', 'dokan-lite' ),
__( 'Single Product Multiple Seller', 'dokan-lite' ),
__( 'Seller Verification', 'dokan-lite' ),
__( 'Featured Seller', 'dokan-lite' ),
__( 'Multiple Commission Types', 'dokan-lite' ),
__( 'Frontend Shipping Tracking', 'dokan-lite' ),
__( 'Setup Wizard', 'dokan-lite' ),
__( 'Google Maps', 'dokan-lite' ),
__( 'Manage reviews', 'dokan-lite' ),
__( 'Bookable Product', 'dokan-lite' ),
__( 'Settings', 'dokan-lite' ),
__( 'Dismiss this notice.', 'dokan-lite' ),
__( 'Choose your file', 'dokan-lite' ),
__( 'Withdraw Requests', 'dokan-lite' ),
__( 'Update Note', 'dokan-lite' ),
__( '(no name)', 'dokan-lite' ),
__( 'No requests found.', 'dokan-lite' ),
__( 'Vendor', 'dokan-lite' ),
__( 'Amount', 'dokan-lite' ),
__( 'Status', 'dokan-lite' ),
__( 'Method', 'dokan-lite' ),
__( 'Details', 'dokan-lite' ),
__( 'Note', 'dokan-lite' ),
__( 'Date', 'dokan-lite' ),
__( 'Actions', 'dokan-lite' ),
__( 'Delete', 'dokan-lite' ),
__( 'Cancel', 'dokan-lite' ),
__( 'Approve', 'dokan-lite' ),
__( 'Download PayPal mass payment file', 'dokan-lite' ),
__( 'Are you sure?', 'dokan-lite' ),
__( 'Account Name: %s', 'dokan-lite' ),
__( ', Account Number: %s', 'dokan-lite' ),
__( ', Bank Name: %s', 'dokan-lite' ),
__( ', Routing Number: %s', 'dokan-lite' ),
];
Loading

4 comments on commit 8c2af82

@ManigandanRaamanathan
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works with which version of Woocommerce rest api?

@saimonh3
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should use the latest version of WooCommerce REST API which is v2 @ManigandanRaamanathan

@ManigandanRaamanathan
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. Trying I'll try with that

@ManigandanRaamanathan
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now it assigning the order to the particular vendor in the admin page. But it is still not showing the order in the vendor page.

Please sign in to comment.