File tree Expand file tree Collapse file tree 6 files changed +42
-7
lines changed Expand file tree Collapse file tree 6 files changed +42
-7
lines changed Original file line number Diff line number Diff line change 2626 "postsList" : " blog/post/getList" ,
2727 "addBlogPostReview" : " blog/review/add" ,
2828
29+ "checkoutLink" : " store/checkout/link" ,
30+
2931 "cart" : " store/cart/get" ,
3032 "addToCart" : " store/cart/add" ,
3133 "updateCart" : " store/cart/update" ,
Original file line number Diff line number Diff line change @@ -37,9 +37,10 @@ public function getProductAttributes($product_id)
3737
3838 public function getOptionValues ($ taxonomy ) {
3939 global $ wpdb ;
40-
40+
4141 $ result = $ wpdb ->get_results ("SELECT
42- t.`name`
42+ t.`name`,
43+ t.`slug`
4344 FROM
4445 `wp_term_taxonomy` tt
4546 LEFT JOIN `wp_terms` t ON t.`term_id` = tt.`term_id`
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ public function add($args) {
1313 $ options [ $ option ['id ' ] ] = $ option ['value ' ];
1414 }
1515 $ variation_id = $ this ->find_matching_product_variation_id ($ args ['id ' ], $ options );
16+
1617 WC ()->cart ->add_to_cart ($ args ['id ' ], $ args ['quantity ' ], $ variation_id );
1718 } else {
1819 WC ()->cart ->add_to_cart ($ args ['id ' ], $ args ['quantity ' ]);
@@ -32,7 +33,7 @@ public function remove($args) {
3233 }
3334 public function get ($ args ) {
3435 $ cart = array ();
35-
36+ $ this -> load -> model ( ' store/product ' );
3637 $ cart ['products ' ] = array ();
3738 foreach (WC ()->cart ->get_cart () as $ product ) {
3839 if ($ product ['variation_id ' ] !== 0 ) {
@@ -44,10 +45,15 @@ public function get($args) {
4445 'key ' => $ product ['key ' ],
4546 'product ' => $ this ->load ->resolver ('store/product/get ' , array ( 'id ' => $ product_id )),
4647 'quantity ' => $ product ['quantity ' ],
48+ 'option ' => array (),
4749 'total ' => $ product ['line_total ' ] . ' ' . $ this ->model_store_product ->getCurrencySymbol ()
4850 );
4951 }
5052
53+ $ total = !empty ($ cart ['products ' ]) ? WC ()->cart ->total : 0 ;
54+
55+ $ cart ['total ' ] = $ total . ' ' . $ this ->model_store_product ->getCurrencySymbol ();
56+
5157 return $ cart ;
5258 }
5359
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ class ResolverStoreCheckout extends Resolver
4+ {
5+ public function link () {
6+ return array (
7+ 'link ' => WC ()->cart ->get_checkout_url ()
8+ );
9+ }
10+ }
Original file line number Diff line number Diff line change @@ -46,7 +46,7 @@ public function get($args) {
4646 $ special = '' ;
4747 }
4848 }
49- $ keyword = str_replace (get_site_url (), '' , get_permalink ( $ product ->ID ));
49+ $ keyword = str_replace (get_site_url (), '' , get_post_permalink (( int ) $ product ->ID ));
5050 $ keyword = trim ($ keyword , '/? ' );
5151 $ keyword = trim ($ keyword , '/ ' );
5252
@@ -101,12 +101,15 @@ public function get($args) {
101101 public function getList ($ args ) {
102102 $ this ->load ->model ('store/product ' );
103103 $ filter_data = array (
104- 'start ' => ($ args ['page ' ] - 1 ) * $ args ['size ' ],
105- 'limit ' => $ args ['size ' ],
106104 'sort ' => $ args ['sort ' ],
107105 'order ' => $ args ['order ' ],
108106 );
109107
108+ if ($ args ['size ' ] != '-1 ' ) {
109+ $ filter_data ['start ' ] = ($ args ['page ' ] - 1 ) * $ args ['size ' ];
110+ $ filter_data ['limit ' ] = $ args ['size ' ];
111+ }
112+
110113 if ($ filter_data ['sort ' ] == 'id ' ) {
111114 $ filter_data ['sort ' ] = 'p.ID ' ;
112115 }
@@ -200,7 +203,7 @@ public function getOptions($data) {
200203
201204 foreach ($ result_values as $ value ) {
202205 $ option_values [] = array (
203- 'id ' => $ value ->name ,
206+ 'id ' => $ value ->slug ,
204207 'name ' => $ value ->name
205208 );
206209 }
Original file line number Diff line number Diff line change @@ -7,16 +7,24 @@ scalar Upload
77
88type Cart {
99 products : [CartProduct ]
10+ total : String
1011}
1112
1213input CartOption {
1314 id : String
1415 value : String
1516}
1617
18+ type CartProductOption {
19+ name : String
20+ value : String
21+ type : String
22+ }
23+
1724type CartProduct {
1825 key : String
1926 product : Product
27+ option : [CartProductOption ]
2028 quantity : Int
2129 total : String
2230}
@@ -307,6 +315,10 @@ type FileResult {
307315 code : String
308316}
309317
318+ type CheckoutLinkResult {
319+ link : String
320+ }
321+
310322type RootMutationType {
311323 uploadFile (file : Upload ): FileResult
312324 accountLogin (email : String , password : String ): Customer
@@ -355,5 +367,6 @@ type RootQueryType {
355367 accountCheckLogged : LoggedResult
356368 accountAddressList : [AccountAddress ]
357369 accountAddress (id : String ): AccountAddress
370+ checkoutLink : CheckoutLinkResult
358371}
359372
You can’t perform that action at this time.
0 commit comments