1

私はレールとShopifyアプリケーションを作ってるんだと私はこれがあります。ジョブのウェブフックデータにアクセスするにはどうすればよいですか? (Shopify Railsの)

webhooks_controller.rb

module ShopifyApp 
    class WebhooksController < ActionController::Base 
     include ShopifyApp::WebhookVerification 

     class ShopifyApp::MissingWebhookJobError < StandardError; end 

     def receive 
     params.try(:permit!) 
     job_args = {shop_domain: shop_domain, webhook: webhook_params.to_h} 
     webhook_job_klass.perform_later(job_args) 
     head :no_content 
     end 

     private 

     def webhook_params 
     params.except(:controller, :action, :type) 
     end 

     def webhook_job_klass 
     "#{webhook_type.classify}Job".safe_constantize or raise ShopifyApp::MissingWebhookJobError 
     end 

     def webhook_type 
     params[:type] 
     end 
    end 
    end 

orders_create_job.rbを

class OrdersCreateJob < ActiveJob::Base 

    def perform(shop_domain:, webhook:) 
    shop = Shop.find_by(shopify_domain: shop_domain) 
    shop.with_shopify_session do 
     #DATA GOES HERE 
    end 
    end 
end 

webhookの変数を "#DATA GOES HERE"に "shipping_l"の "title"のように取得することは可能ですか? ines "?

どうすればいいですか?

答えて

1

データはwebhook引数に含まれています。 の注文にはタイトルがありませんので、webhook [:title]は存在しませんが、ご注文に送料がありますのでwebhook [:shipping_lines]で注文してください。

関連する問題