小编The*_*het的帖子

将用户 ID 分配给在 Woocommerce 3 中以编程方式创建的订单

我正在使用 Woocommerce 在 Wordpress 上管理我的产品,但用户通过 3rd 方服务付款。

我正在尝试手动创建新订单,并将其分配给当前用户。订单确实已创建并记录,但以下代码仅记录项目和时间,没有用户的详细信息:

  global $woocommerce;

  $address = array(
      'first_name' => $_GET['FirstName'],
      'last_name'  => $_GET['LastName'],
      'company'    => $_GET['CompanyName'],
      'email'      => $_GET['EmailAddress'],
      'phone'      => $_GET['MobilePhoneNumber'],
      'address_1'  => '',
      'address_2'  => '',
      'city'       => '',
      'state'      => '',
      'postcode'   => '',
      'country'    => $_GET['countryCode']
  );

  $order = wc_create_order();

  foreach ($woocommerce->cart->get_cart() as $cart_item_key => $values) {
            $item_id = $order->add_product(
                    $values['data'], $values['quantity'], array(
                'variation' => $values['variation'],
                'totals' => array(
                    'subtotal' => $values['line_subtotal'],
                    'subtotal_tax' => $values['line_subtotal_tax'],
                    'total' => $values['line_total'], …
Run Code Online (Sandbox Code Playgroud)

php wordpress orders woocommerce

4
推荐指数
1
解决办法
5302
查看次数

使用laravel编辑用户信息

我在我的网站上为管理员构建了一个cms界面.除其他外,管理员可以使用表单添加\编辑用户信息.当我发送编辑表单时,我不断收到此错误:Column not found: 1054 Unknown column 'updated_at' in 'field list'这表明数据库更新正在尝试保存所有请求索引(包含其他表中列的值),而不仅仅是我正在尝试更新的索引.

我已设法将问题跟踪到一行$user_role->save();.上面的行做他们想做的事情(找到thr correcct user_role并改变它的值).

这是我的代码

模型

static public function update_user($request, $id){
        
        $image_name = '';

        if( !empty($request['profile_image']) && $request->hasFile('profile_image') && $request->file('profile_image')->isValid() ){

            $file = $request->file('profile_image');
            $image_name = date('Y.m.d.H.i.s') . '-' . $file->getClientOriginalName();
            $request->file('profile_image')->move( public_path() . '/images/profile-images/' , $image_name);
            $img = Image::make( public_path() . '/images/profile-images/' . $image_name );
            $img->resize(370, null, function ($constraint) {
                $constraint->aspectRatio();
            });
            $img->save();

        }
        $user = self::find($id);
        $user->name = $request['name'];
        $user->email = $request['email'];
        $user->phone = $request['phone']; …
Run Code Online (Sandbox Code Playgroud)

laravel eloquent laravel-5 laravel-migrations

0
推荐指数
1
解决办法
32
查看次数