Migrating Pre-Order app to Selling Plan API

Solved

Migrating Pre-Order app to Selling Plan API

Lokesh_Saini
Shopify Partner
5 1 0
We have a pre-order app published on the Shopify app store, and we want to upgrade it using a selling plan. 
 
We want to create a selling plan that will charge 100% money of the order at the checkout. It seems to be working at the backend (Screenshot1.png) but it is not working in the front store(Screenshot2.png) 
 
Current Behavior:-
 
When the purchase option is enabled (Screenshot3.png) from the backend then the total value of the product at the checkout is 0 (Screenshot2.png) but when we disable the purchase option (Screenshot4.png) from the backend then the full price of the product is displayed at checkout (Screenshot5.png).
 
Expected Behavior:-
 
When the purchase option is enabled (Screenshot3.png) from the backend then the total value of the product at the checkout will be charged&nbsp, and when we disable the purchase option (Screenshot4.png) from the backend then the full price of the product is displayed at checkout (Screenshot5.png) as the default behavior.

My Code for creating a selling plan:-

 

 

 

$query = '
            mutation {
                sellingPlanGroupCreate(
                    input: {
                        name: "Pre-order"
                        merchantCode: "pre-order"
                        options: [
                            "Pre-order"
                        ]
                        sellingPlansToCreate: [
                        {
                            name: "Pre Order Product with 100% deposit"
                            category: PRE_ORDER
                            options: [
                                "100% deposit. No Due Balance"
                            ]
                            billingPolicy: {
                                fixed: {
                                    checkoutCharge: {type: PERCENTAGE, value: {percentage: 100.0}}
                                    remainingBalanceChargeTrigger: NO_REMAINING_BALANCE
                                }
                            }
                            pricingPolicies: [
                                {
                                    fixed: {
                                        adjustmentType: PERCENTAGE
                                        adjustmentValue: { percentage: 0.0 }
                                    }
                                }
                            ]
                            deliveryPolicy: {fixed: {fulfillmentTrigger: UNKNOWN}}
                            inventoryPolicy: {reserve: ON_FULFILLMENT}
                        }
                        ]
                    }
                    resources: {productVariantIds: [], productIds: []}
                ) {
                    sellingPlanGroup {
                        id
                    }
                    userErrors {
                        field
                        message
                    }
                }
            }';

            $response = $shopifyObj->GraphQL->post($query);​

 

 

 

 

 

Here is the code for adding the product to Selling Plan:-

 

 

 

 

$query=<<<QUERY
                mutation {
                sellingPlanGroupAddProducts(
                    id: "$selling_plan_id"
                    productIds: $productIds
                ) {
                    sellingPlanGroup {
                        id
                    }
                    userErrors {
                        field
                        message
                    }
                }
            }
            QUERY;

            $pr = $shopifyObj->GraphQL->post($query);​

 

 

 


and here is the code for adding variants to the Selling Plan:-

 

 

 

 

$query=<<<QUERY
                mutation {
                sellingPlanGroupAddProductVariants(
                    id: "$selling_plan_id"
                    productVariantIds: $variants_ids
                ) {
                    sellingPlanGroup {
                        id
                    }
                    userErrors {
                        field
                        message
                    }
                }
            }
            QUERY;

            self::$shopify->GraphQL->post($query);​

 

 

 

 

Please suggest to me what I am doing wrong. See my GraphQL API code screenshot (Screenshot6.png).
 
Hope you Understand the problem.

I'm very frustrated about this problem please help me to get out of this.

Thank You in advance

Screenshot1.png
 

Screenshot1.png

 

 Screenshot2.png

 

Screenshot2.png

 

 Screenshot3.png

 

Screenshot3.png

 

Screenshot4.png

 

Screenshot4.png

 

Screenshot5.png

 

Screenshot5.png

 

Accepted Solution (1)

Lokesh_Saini
Shopify Partner
5 1 0

This is an accepted solution.

I identified the root cause of the problem -

I had not integrated any payment provider with my Shopify store. Consequently, the checkout price was displayed as 0.

However, after adding PayPal Express to my store, everything is functioning properly now.

View solution in original post

Replies 3 (3)

Lokesh_Saini
Shopify Partner
5 1 0

This is an accepted solution.

I identified the root cause of the problem -

I had not integrated any payment provider with my Shopify store. Consequently, the checkout price was displayed as 0.

However, after adding PayPal Express to my store, everything is functioning properly now.

Nazar4
Shopify Partner
7 0 1

Hello!
Can you tell me how you do the editing sellingPlanGroupUpdate? You need an ID ( "id": "gid://shopify/SellingPlan/422674488") for this, and the documentation doesn't say anything about it where you can get it.

Lokesh_Saini
Shopify Partner
5 1 0

Absolutely! For editing the sellingPlanGroupUpdate endpoint, we require an ID. Your comment contains the ID for a sellingPlan, but we actually need the ID for a sellingPlanGroup.