2016-08-06 4 views
0

WooCommerece API를 독립적이고 독립적 인 PHP 파일로 활용할 수 있습니까? 예를 들어, 하루 동안 모든 매출을 계산하는 PHP 스크립트를 실행하고 싶습니다. 파일은 WooCommerence 폴더에 있지만 WordPress 또는 WooCommerence 설치에 연결되지 않습니다.독립적 인 WooCommerce 논리 - 포함?

예 : salesTally.php

<?php 
//How to include? 
global $woocommerce, $post; 

$order = new WC_Order($post->ID); 

//Do Stuff To Order 

?> 
+1

예, 해당 파일 – silver

+0

감사 실버에 바로로드 WP-load.php. 아래 해결 방법. – Colin

답변

0

은 고맙습니다.

가능한 해결 방법 :

include_once('wp-load.php'); 
global $woocommerce; 
//Search for complete wc_bookings, return a maximum of 200 
$orders = get_posts(array(
     'post_type' => 'wc_booking', 
     'post_status' => 'complete', 
     'posts_per_page' => 200 
)); 

print_r($orders);