【问题标题】:How to get the users detail info in api call in cs-cart?如何在 cs-cart 的 api 调用中获取用户详细信息?
【发布时间】:2019-05-19 16:23:47
【问题描述】:

我正在尝试通过 CS-cart 中的 api 检索用户信息。但它只返回有限的信息。我们如何修改代码以获取前用户个人资料、地址、gst 等所有用户信息。

【问题讨论】:

    标签: cs-cart


    【解决方案1】:

    您可以创建自己的 API。

    /var/www/html/app/addons/addon_name/Tygh/Api/Entities/Egg.php

        <?php 
    namespace Tygh\Api\Entities;
    
    use Tygh\Api\AEntity;
    use Tygh\Api\Response;
    
    class Egg extends AEntity
    {
        public function index($id = '', $params = array())
        {
            if(empty($id))
            {
                $dd=db_get_array("SELECT * FROM ?:table_name");
                //result all rows
            }
            else
            {
                // for filtering purpose
                $where=array("id"=>$id);
                $dd=db_get_array("SELECT * FROM ?:table_name where ?w",$where);
                //result-> specific one row
            }
            return array(
                'status' => Response::STATUS_OK,
                'data' => $dd
            );
        }
    
        public function create($params)
        {
            return array(
                'status' => Response::STATUS_OK,
                'data' => array()
            );
        }
    
        public function update($id, $params)
        {
            return array(
                'status' => Response::STATUS_OK,
                'data' => array()
            );
        }
    
        public function delete($id)
        {
            return array(
                'status' => Response::STATUS_NO_CONTENT,
            );
        }
    
        public function privileges()
        {
            return array(
                'index' => true,
                'create' => 'create_things',
                'update' => 'edit_things',
                'delete' => 'delete_things',
                'index'  => 'view_things'
            );
        }
        public function privilegesCustomer()
        {
            return array(
                'index' => true
            );
        }
    }
    ?>
    

    备注: 文件名, 班级名称, 文件路径

    【讨论】:

      【解决方案2】:

      或者您可以从此位置编辑用户 API 实体。

      app/Tygh/Api/Entities/Users.php
      

      有任何疑问,然后踢我...

      【讨论】:

      • 我添加了其他字段并且我正在获取相关信息...但是我如何获取与用户关联的配置文件字段信息。
      • cscart_users 和 cscart_user_profiles 表是允许用户个人资料字段信息
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-30
      相关资源
      最近更新 更多