Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add .current method back to ShopifyAPI::Shop and ShopifyAPI::RecurringApplicationCharge #923

Open
scart88 opened this issue Apr 11, 2022 · 27 comments

Comments

@scart88
Copy link

scart88 commented Apr 11, 2022

Issue summary

With the new breaking api change, ShopifyAPI::Shop.current, ShopifyAPI::RecurringApplicationCharge.current methods are missing. Is there any plan in adding these back?

Expected behavior

ShopifyAPI::Shop.current should return the current shop from the session.

Actual behavior

Right now it returns
NoMethodError: undefined method 'current' for ShopifyAPI::Shop:Class

Previous implementation

def current
  (all || []).find { |c| c.status == 'active' }
end

Steps to reproduce the problem

Shop.first.with_shopify_session do
  puts ShopifyAPI::Shop.current
end 

Loading development environment (Rails 7.0.2.3)
[1] pry(main)> Shop.first.with_shopify_session { ShopifyAPI::Shop.current }
  Shop Load (7.4ms)  SELECT "shops".* FROM "shops" ORDER BY "shops"."id" ASC LIMIT $1  [["LIMIT", 1]]
NoMethodError: undefined method `current' for ShopifyAPI::Shop:Class
from (pry):1:in `block in __pry__'
[2] pry(main)> 

Specifications

  • shopify_api version: 10.0.0
  • Shopify API version used (example: 2022-04): 2022-04
@mllemango
Copy link
Contributor

We're adding this to the TODO list! Keeping this issue open to let others also chime in their feedback

@uurcank
Copy link

uurcank commented Apr 14, 2022

@mllemango this is a breaking change was not mentioned in docs. It has been widely used so please add it back.

@BentoumiTech
Copy link

Do there is any similar method that it has been replaced with ?

@stuartchaney
Copy link

+1, this was the last hurdle that prevented us from upgrading version :(

@marisveide
Copy link

+1 from me as well.

@kaarelss
Copy link
Contributor

+1 from me as well

@jaredbeck
Copy link

jaredbeck commented Nov 11, 2022

I, also, do not see any mention of this breaking change in the changelog. Will the changelog be updated?

Until this method is restored, what is the workaround?

@axlekb
Copy link

axlekb commented Nov 11, 2022

This works: ShopifyAPI::Shop.all[0]

@asecondwill
Copy link

@axlekb @mllemango - does this workaround really work reliably? It isnt very descriptive. At first glance it could just get the first shop that has this app or something.

Like the others above, I used the ShopifyAPI::Shop.current method a lot. Upgrading to shopify_app 20+ and so shopify API 10+ is being presented as mandatory by the approvals team, including delisting our app and saying we have to update to be re-evaluated. So it's pretty important this stuff is either put right or workarounds / changes properly documented.

@sativva
Copy link

sativva commented Nov 29, 2022

I'm using that instead, waiting for upgrase. xo

ShopifyAPI::Shop.all(session: @session).first

@fluke
Copy link

fluke commented Dec 1, 2022

ShopifyAPI::RecurringApplicationCharge.current can be replaced with (ShopifyAPI::RecurringApplicationCharge.all || []).find { |c| c.status == 'active' }

@immakdas
Copy link

immakdas commented Dec 1, 2022

Sometimes I think the dev team in Shopify has no idea what they are doing. Instead of improving, things became harder to handle. Current app version is v21 but you still have to write tons of custom code to handle payments, trial/ decline payments etc

@sagar-ranglani
Copy link

This works: ShopifyAPI::Shop.all[0]

Does this really work?

@kirillplatonov
Copy link

The old method was very convenient. Not sure what was the motivation for removing it during the rewrite. For now, I added this to my Rails initializer to restore old behavior:

# config/initializers/shopify_app.rb

Rails.application.config.after_initialize do
  class ShopifyAPI::Shop
    def self.current(session: ShopifyAPI::Context.active_session, fields: nil)
      ShopifyAPI::Shop.all(session: session, fields: fields).first
    end
  end
end

@github-actions
Copy link

github-actions bot commented Mar 7, 2023

This issue is stale because it has been open for 60 days with no activity. It will be closed if no further action occurs in 14 days.

@github-actions github-actions bot added the Stale label Mar 7, 2023
@sagar-ranglani
Copy link

Any updates on this?

@github-actions github-actions bot removed the Stale label Mar 10, 2023
@jefflewis
Copy link

This is still a major missing feature that we're all having to add to our codebases.

When this library was rewritten, the V10 changelog says this:

We've rewritten this library for v10, so that it provides all essential features for a Shopify app without depending on the Active Resource or graphql-client libraries.

This issue is glaring proof that "all essential features" are not yet provided. This version should have stayed a "beta" release or something like it until a minimum amount of feature parity was in place. The "upgrade" of this gem in order to meet with Shopify's required changes feels like it has been done with very little consideration of the users of this library.

In short, here's my 👍 for adding this (and so many similar) convenience features back to this library so I an get rid of all these monkey patches I'm adding in the gem initializer.

@github-actions
Copy link

This issue is stale because it has been open for 60 days with no activity. It will be closed if no further action occurs in 14 days.

@github-actions github-actions bot added the Stale label May 18, 2023
@scart88
Copy link
Author

scart88 commented May 18, 2023

Any updates on this?

@github-actions github-actions bot removed the Stale label May 19, 2023
@github-actions
Copy link

This issue is stale because it has been open for 60 days with no activity. It will be closed if no further action occurs in 14 days.

@github-actions github-actions bot added the Stale label Jul 18, 2023
@kirillplatonov
Copy link

Not stale

@skillmatic-co
Copy link

To put it bluntly - developing for shopify is literally the worst. Changelogs suck. Usage docs suck. Upgrades suck. I'm still stuck at <V10 because there were so many breaking changes from 9 to 10 that my entire custom app would need a rewrite and I have a hard time explaining that to my client.

@github-actions github-actions bot removed the Stale label Jul 19, 2023
@Icmus23
Copy link

Icmus23 commented Jul 21, 2023

I'm currently using this approach:

client = ShopifyAPI::Clients::Rest::Admin.new(session: @session)
client.get(path: 'shop')

@github-actions
Copy link

This issue is stale because it has been open for 60 days with no activity. It will be closed if no further action occurs in 14 days.

@github-actions github-actions bot added the Stale label Sep 20, 2023
@jefflewis
Copy link

Not stale.

@github-actions github-actions bot removed the Stale label Sep 21, 2023
@ziaulrehman40
Copy link

Wow, so long and nothing!

@djkgamc
Copy link

djkgamc commented May 17, 2024

annoying

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet