LoginSignup
28
47

More than 3 years have passed since last update.

商品購入後の商品にSOLDを表記(某フリマアプリのSOLD機能)

Last updated at Posted at 2019-08-14

前提条件

Payjpに登録したクレジットカードで商品購入を実装する(Rails)

を参考に実装しました。

1.購入ボタンを押したら購入者のIDが商品に登録されるように実装

purchase_controller
def  done
 @product_purchaser= Product.find(params[:id])
 @product_purchaser.update( purchaser_id: current_user.id)
end

2.商品一覧の商品にSOLDを記載

index.html.haml
      -if product.purchaser_id.present? 
        .items-box_photo__sold
          .items-box_photo__sold__inner
            SOLD

上記のコードを商品の個別の枠の一番下に配置

index.scss
  .items-box_photo__sold{
    width: 0;
    height: 0;
    border-top: 60px solid #ea352d ;
    border-right: 60px solid transparent;
    border-bottom: 60px solid transparent;
    border-left: 60px solid #ea352d ;
    z-index:100;
    position: relative;
    top:-320px;
    &__inner{
      transform: rotate(-45deg);
      font-size: 28px;
      margin:-35px 0px 0px -55px;
      color: #fff;
      letter-spacing: 2px;
      font-weight: 600;
    }
  }

商品詳細がある場合も同様に実施

394b2565159434840c5ea18302271fce.png

こんな感じ!!

28
47
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
28
47