Skip to content

I am trying to obtain a list of orders with over 250 contents #314

Description

@aogg2023

namespace app\api\controller;
use commonfunctions\src\Commonfunctions;
use think\Controller;
use app\api\controller\Baiduimages;
use app\api\controller\Spapi;

use PHPShopify\ShopifySDK;

class Shopify extends Controller {

protected function _initialize(){

    $commonfunctions=	new Commonfunctions;
    $Baiduimages=	new Baiduimages;
    $Spapi=	new Spapi;
    
}

protected function shopinfo($admin_id){
    
    $shop=db("admin_extend")->where(array("admin_id"=>$admin_id))->find();
    
    $shopname = $shop["store_name"] . ".myshopify.com";
    $apiKey = $shop["api_key"];
    $apiPassword = $shop["password"];
    $apiVersion = '2023-10';
    
    $config = array(
        'ShopUrl' => $shopname,
        'ApiKey' => $apiKey,
        'Password' => $apiPassword,
        'ApiVersion' => $apiVersion,
        'isEmbeddedApp' => false,
        'isPrivateApp' => false,
        'Curl' => array(
            CURLOPT_SSL_VERIFYPEER => false,
            CURLOPT_SSL_VERIFYHOST => false
        )
    );

    $shopify = new ShopifySDK($config);
    
    return $shopify;
    
}


//获取订单
public function get_orders(){
    
    //$products = $shopify->Product->get();
    
    //$productsCount = $shopify->Order->count();
    
    
    $id="";
    if(isset($orderid)){
        $id=$orderid;
    }
    
    $shopify=$this->shopinfo(2395);
  
    $fields="id,total_price,subtotal_price,total_discounts,total_tax,total_weight,currency,".
            "financial_status,fulfillment_status,note,created_at,processed_at,closed_at,location_id,email,".
            "shipping_address,line_items,order_number,fulfillments,shipping_lines,customer,payment_gateway_names,tags";
    
    $params = array(
        'status' => 'any',
        'limit' => 250,
        'fields' => $fields
    );
    
    $orders = $shopify->Order($id)->get($params);
    
    return $orders;
    
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions