當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Base::getDefaultModelSettings方法代碼示例

本文整理匯總了PHP中Base::getDefaultModelSettings方法的典型用法代碼示例。如果您正苦於以下問題:PHP Base::getDefaultModelSettings方法的具體用法?PHP Base::getDefaultModelSettings怎麽用?PHP Base::getDefaultModelSettings使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Base的用法示例。


在下文中一共展示了Base::getDefaultModelSettings方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getModelSettings

 public static function getModelSettings()
 {
     include WCAPIDIR . "/_globals.php";
     $table = array_merge(Base::getDefaultModelSettings(), array('model_conditions' => "WHERE post_type IN ('shop_order') AND post_status != 'trash'", 'has_many' => array('order_items' => array('class_name' => 'OrderItem', 'foreign_key' => 'order_id', 'conditions' => "order_item_type = 'line_item'"), 'tax_items' => array('class_name' => 'OrderTaxItem', 'foreign_key' => 'order_id', 'conditions' => "order_item_type = 'tax'"), 'coupon_items' => array('class_name' => 'OrderCouponItem', 'foreign_key' => 'order_id', 'conditions' => "order_item_type = 'coupon'"), 'notes' => array('class_name' => 'Comment', 'foreign_key' => 'comment_post_ID', 'conditions' => array("comment_type IN ('order_note')", "comment_approved != 'trash'")))));
     $table = apply_filters("WCAPI_order_model_settings", $table);
     return $table;
 }
開發者ID:borisdiakur,項目名稱:woocommerce-json-api,代碼行數:7,代碼來源:Order.php

示例2: getModelSettings

 public static function getModelSettings()
 {
     include WCAPIDIR . "/_globals.php";
     $table = array_merge(Base::getDefaultModelSettings(), array('model_table' => $wpdb->prefix . 'woocommerce_order_items', 'meta_table' => $wpdb->prefix . 'woocommerce_order_itemmeta', 'model_table_id' => 'order_item_id', 'meta_table_foreign_key' => 'order_item_id', 'meta_function' => 'woocommerce_get_order_item_meta', 'belongs_to' => array('order' => array('class_name' => 'Order', 'foreign_key' => 'order_id'), 'product' => array('class_name' => 'Product', 'meta_attribute' => 'product_id'))));
     $table = apply_filters('WCAPI_order_item_model_settings', $table);
     return $table;
 }
開發者ID:borisdiakur,項目名稱:woocommerce-json-api,代碼行數:7,代碼來源:OrderItem.php

示例3: getModelSettings

 public static function getModelSettings()
 {
     include WCAPIDIR . "/_globals.php";
     $table = array_merge(Base::getDefaultModelSettings(), array('model_table' => $wpdb->comments, 'meta_table' => $wpdb->commentmeta, 'model_table_id' => 'comment_ID', 'meta_table_foreign_key' => 'comment_id', 'meta_function' => 'get_comment_meta', 'update_meta_function' => 'update_comment_meta', 'belongs_to' => array('order' => array('class_name' => 'Order', 'foreign_key' => 'comment_post_ID'))));
     $table = apply_filters('WCAPI_comment_model_settings', $table);
     return $table;
 }
開發者ID:borisdiakur,項目名稱:woocommerce-json-api,代碼行數:7,代碼來源:Comment.php

示例4: getModelSettings

 public static function getModelSettings()
 {
     include WCAPIDIR . "/_globals.php";
     $table = array_merge(Base::getDefaultModelSettings(), array('model_table' => $wpdb->posts, 'meta_table' => $wpdb->postmeta, 'model_table_id' => 'id', 'meta_table_foreign_key' => 'post_id', 'model_conditions' => "WHERE post_type IN ('attachment') AND post_status NOT IN ('trash','auto-draft')"));
     $table = apply_filters('WCAPI_image_model_settings', $table);
     return $table;
 }
開發者ID:borisdiakur,項目名稱:woocommerce-json-api,代碼行數:7,代碼來源:Image.php

示例5: getModelSettings

 public static function getModelSettings()
 {
     include WCAPIDIR . "/_globals.php";
     $table = array_merge(Base::getDefaultModelSettings(), array('model_table' => $wpdb->posts, 'meta_table' => $wpdb->postmeta, 'model_table_id' => 'id', 'meta_table_foreign_key' => 'post_id', 'model_conditions' => "WHERE post_type IN ('shop_coupon') AND post_status NOT IN ('trash','auto-draft')", 'has_many' => array('order_items' => array('class_name' => 'OrderItem', 'foreign_key' => 'order_id'), 'categories' => array('class_name' => 'Category', 'foreign_key' => '', 'sql' => "SELECT t.term_id FROM \n                {$wpdb->terms} AS t, \n                {$wpdb->term_taxonomy} AS tt, \n                {$wpdb->term_relationships} AS tr \n              WHERE\n                tr.object_id = %s AND\n                tt.term_taxonomy_id = tr.term_taxonomy_id AND\n                tt.taxonomy = 'product_cat' AND\n                t.term_id = tt.term_id\n              ", 'connect' => function ($product, $category) {
         include WCAPIDIR . "/_globals.php";
         $product->insert($wpdb->term_relationships, array('object_id' => $product->_actual_model_id, 'term_taxonomy_id' => $category->taxonomy_id));
     }), 'tags' => array('class_name' => 'Category', 'foreign_key' => '', 'sql' => "SELECT t.term_id FROM \n                {$wpdb->terms} AS t, \n                {$wpdb->term_taxonomy} AS tt, \n                {$wpdb->term_relationships} AS tr \n              WHERE\n                tr.object_id = %s AND\n                tt.term_taxonomy_id = tr.term_taxonomy_id AND\n                tt.taxonomy = 'product_tag' AND\n                t.term_id = tt.term_id\n              ", 'connect' => function ($product, $tag) {
         include WCAPIDIR . "/_globals.php";
         $product->insert($wpdb->term_relationships, array('object_id' => $product->_actual_model_id, 'term_taxonomy_id' => $tag->taxonomy_id));
     }))));
     $table = apply_filters('WCAPI_coupon_model_settings', $table);
     return $table;
 }
開發者ID:borisdiakur,項目名稱:woocommerce-json-api,代碼行數:13,代碼來源:Coupon.php

示例6: getModelSettings

 public static function getModelSettings()
 {
     include WCAPIDIR . "/_globals.php";
     $table = array_merge(Base::getDefaultModelSettings(), array('model_table' => $wpdb->posts, 'meta_table' => $wpdb->postmeta, 'model_table_id' => 'id', 'meta_table_foreign_key' => 'post_id', 'model_conditions' => "WHERE post_type IN ('product','product_variation') AND post_status NOT IN ('trash','auto-draft')", 'has_many' => array('order_items' => array('class_name' => 'OrderItem', 'foreign_key' => 'order_id'), 'categories' => array('class_name' => 'Category', 'foreign_key' => '', 'sql' => "SELECT t.term_id FROM \n                {$wpdb->terms} AS t, \n                {$wpdb->term_taxonomy} AS tt, \n                {$wpdb->term_relationships} AS tr \n              WHERE\n                tr.object_id = %s AND\n                tt.term_taxonomy_id = tr.term_taxonomy_id AND\n                tt.taxonomy = 'product_cat' AND\n                t.term_id = tt.term_id\n              ", 'connect' => function ($product, $category) {
         $product->connectToCategory($category);
     }, 'disconnect' => function ($product, $category) {
         $product->disconnectFromCategory($category);
     }), 'tags' => array('class_name' => 'Category', 'foreign_key' => '', 'sql' => "SELECT t.term_id FROM \n                {$wpdb->terms} AS t, \n                {$wpdb->term_taxonomy} AS tt, \n                {$wpdb->term_relationships} AS tr \n              WHERE\n                tr.object_id = %s AND\n                tt.term_taxonomy_id = tr.term_taxonomy_id AND\n                tt.taxonomy = 'product_tag' AND\n                t.term_id = tt.term_id\n              ", 'connect' => function ($product, $tag) {
         $product->connectToCategory($tag);
     }, 'disconnect' => function ($product, $tag) {
         $product->disconnectFromCategory($tag);
     }), 'reviews' => array('class_name' => 'Review', 'foreign_key' => 'comment_post_ID', 'conditions' => array("comment_approved != 'trash'")), 'images' => array('class_name' => 'Image', 'sql' => function ($product) {
         $product_gallery = get_post_meta($product->_actual_model_id, "_product_image_gallery", true);
         if (empty($product_gallery)) {
             return null;
         }
         $img = new Image();
         $s = $img->getModelSettings();
         $sql = "SELECT {$s['model_table_id']} FROM {$s['model_table']} WHERE  {$s['model_table_id']} IN ({$product_gallery})";
         return $sql;
     }, 'connect' => function ($product, $image) {
         $product->connectToImage($image);
     }, 'disconnect' => function ($product, $image) {
         $product->disconnectFromImage($image);
     }), 'featured_image' => array('class_name' => 'Image', 'foreign_key' => 'post_parent', 'sql' => function ($model) {
         $s = $model->getModelSettings();
         $tid = get_post_thumbnail_id($model->_actual_model_id);
         if (empty($tid)) {
             return false;
         }
         $parts = array("post_type = 'attachment'", "post_mime_type IN ('image/jpeg','image/png','image/gif')", "ID = {$tid}");
         return "SELECT {$s['model_table_id']} FROM {$s['model_table']} WHERE " . join(' AND ', $parts);
     }, 'connect' => function ($product, $image) {
         update_post_meta($product->_actual_model_id, '_thumbnail_id', $image->_actual_model_id);
         // Don't need to do this...hrmm
     }), 'variations' => array('class_name' => 'Product', 'foreign_key' => 'post_parent', 'conditions' => array("post_type = 'product_variation'")))));
     $table = apply_filters('WCAPI_product_model_settings', $table);
     return $table;
 }
開發者ID:borisdiakur,項目名稱:woocommerce-json-api,代碼行數:39,代碼來源:Product.php


注:本文中的Base::getDefaultModelSettings方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。