Title: Restricted Order on creating programmatically
Last modified: December 18, 2023

---

# Restricted Order on creating programmatically

 *  [discretemicros](https://wordpress.org/support/users/discretemicros/)
 * (@discretemicros)
 * [2 years, 4 months ago](https://wordpress.org/support/topic/restricted-order-on-creating-programmatically/)
 * Hi,
 * When I am creating an order in WC manually the orders are displayed in “Store
   Vendors” page, but when I create order programmatically they are not shown:
 *     ```wp-block-code
        $order = wc_create_order();
               $customer_data = array(
   
                   'first_name' => 'John',
   
                   'last_name' => 'Doe',
   
                   'email' => 'john@example.com',
   
                   'phone' => '123456789',
   
                   'address_1' => '123 Main St',
   
                   'city' => 'Anytown',
   
                   'postcode' => '12345',
   
                   'country' => 'US',
   
               );
   
               // Set customer information for the order
   
               $order->set_address($customer_data, 'billing');
   
                $order->set_address($customer_data, 'shipping');
   
               $product = wc_get_product($product_id);
   
               if ($product) {
   
            
                   $item = $order->add_product($product, 1); // Quantity: 1
   
                   if ($order->get_status() === 'pending') {
   
   
                       $order->update_status('processing');
   
        
                   } else {
   
                       // echo 'Order status is not Pending payment.';
   
                   }
   
                      if ($item) {
   
                       // Calculate totals
   
                       $order->calculate_totals();
   
                       // Update product meta
   
                       // Save the order
   
                       $order->save();
   
                       // Get the order ID
   
                       $order_id = $order->get_id();
   
                            if ($order_id) {
   
            
                           echo 'Order created successfully. Order ID: ' . $order_id;
   
                       } else {
   
                           echo 'Error saving the order.';
   
                       }
   
                   } else {
   
                       echo 'Error adding product to the order.';
   
                   }
   
               } else {
   
                   echo 'Product not found.';
   
               }
   
           }
   
       The notification for order is displayed in this case but when I click on the order id:
   
        Restricted Order: You don't have permission to access this page. Please contact your Store Admin for assistance.
   
       This is shown,
   
       Where i am missingm is there an event need to be triggerred after order creation.
       ```
   

The topic ‘Restricted Order on creating programmatically’ is closed to new replies.

 * ![](https://ps.w.org/wc-multivendor-marketplace/assets/icon-256x256.gif?rev=2611991)
 * [WCFM Marketplace - Multivendor Marketplace for WooCommerce](https://wordpress.org/plugins/wc-multivendor-marketplace/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wc-multivendor-marketplace/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wc-multivendor-marketplace/)
 * [Active Topics](https://wordpress.org/support/plugin/wc-multivendor-marketplace/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wc-multivendor-marketplace/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wc-multivendor-marketplace/reviews/)

 * 0 replies
 * 1 participant
 * Last reply from: [discretemicros](https://wordpress.org/support/users/discretemicros/)
 * Last activity: [2 years, 4 months ago](https://wordpress.org/support/topic/restricted-order-on-creating-programmatically/)
 * Status: not resolved