Blocks
1 year ago
Concerns
1 year ago
Traits
1 year ago
AbandonedCheckout.php
1 year ago
AbandonedCheckoutProtocol.php
3 years ago
Account.php
3 years ago
AccountPortalSession.php
4 years ago
Activation.php
1 year ago
Affiliation.php
1 year ago
AffiliationProduct.php
1 year ago
AffiliationProtocol.php
2 years ago
AffiliationRequest.php
1 year ago
ApiToken.php
3 years ago
BalanceTransaction.php
1 year ago
Brand.php
4 years ago
BulkAction.php
2 years ago
Bump.php
1 year ago
BuyLink.php
2 years ago
CancellationAct.php
1 year ago
CancellationReason.php
3 years ago
Charge.php
1 year ago
Checkout.php
1 year ago
Click.php
1 year ago
Collection.php
2 years ago
CommissionStructure.php
2 years ago
Component.php
4 years ago
Coupon.php
1 year ago
Customer.php
1 year ago
CustomerLink.php
4 years ago
CustomerNotificationProtocol.php
4 years ago
CustomerPortalProtocol.php
1 year ago
DatabaseModel.php
1 year ago
Discount.php
1 year ago
Download.php
4 years ago
Event.php
4 years ago
Export.php
2 years ago
ExternalApiModel.php
1 year ago
Form.php
3 years ago
Fulfillment.php
1 year ago
FulfillmentItem.php
1 year ago
GalleryItem.php
1 year ago
GalleryItemAttachment.php
1 year ago
GalleryItemMedia.php
1 year ago
GalleryItemProductMedia.php
1 year ago
IncomingWebhook.php
1 year ago
Integration.php
2 years ago
IntegrationCatalog.php
1 year ago
Invoice.php
1 year ago
License.php
1 year ago
LineItem.php
1 year ago
ManualPaymentMethod.php
1 year ago
Media.php
1 year ago
Model.php
1 year ago
ModelInterface.php
4 years ago
Order.php
1 year ago
OrderProtocol.php
4 years ago
PaymentFailure.php
1 year ago
PaymentInstrument.php
1 year ago
PaymentIntent.php
4 years ago
PaymentMethod.php
1 year ago
Payout.php
1 year ago
PayoutGroup.php
2 years ago
Period.php
1 year ago
PortalSession.php
4 years ago
Price.php
1 year ago
Processor.php
1 year ago
Product.php
1 year ago
ProductCollection.php
1 year ago
ProductGroup.php
1 year ago
ProductMedia.php
1 year ago
Promotion.php
1 year ago
ProvisionalAccount.php
2 years ago
Purchase.php
2 years ago
Referral.php
1 year ago
ReferralItem.php
2 years ago
Refund.php
1 year ago
RegisteredWebhook.php
2 years ago
ReturnItem.php
2 years ago
ReturnReason.php
2 years ago
ReturnRequest.php
1 year ago
ShippingMethod.php
3 years ago
ShippingProfile.php
3 years ago
ShippingProtocol.php
3 years ago
ShippingRate.php
3 years ago
ShippingZone.php
3 years ago
Statistic.php
4 years ago
Subscription.php
1 year ago
SubscriptionProtocol.php
4 years ago
TaxOverride.php
2 years ago
TaxProtocol.php
4 years ago
TaxRegistration.php
1 year ago
TaxZone.php
4 years ago
Upload.php
4 years ago
Upsell.php
1 year ago
UpsellFunnel.php
1 year ago
User.php
2 years ago
Variant.php
1 year ago
VariantOption.php
2 years ago
VariantOptionValue.php
1 year ago
VariantValue.php
2 years ago
VerificationCode.php
3 years ago
Webhook.php
1 year ago
WebhookRegistration.php
2 years ago
IntegrationCatalog.php
97 lines
| 1 | <?php |
| 2 | |
| 3 | namespace SureCart\Models; |
| 4 | |
| 5 | /** |
| 6 | * The integration listing model. |
| 7 | */ |
| 8 | class IntegrationCatalog extends ExternalApiModel { |
| 9 | /** |
| 10 | * Rest API endpoint |
| 11 | * |
| 12 | * @var string |
| 13 | */ |
| 14 | protected $endpoint = 'v1'; |
| 15 | |
| 16 | /** |
| 17 | * Default query parameters |
| 18 | * |
| 19 | * @var array |
| 20 | */ |
| 21 | protected $default_query = [ |
| 22 | '_embed' => true, |
| 23 | '_fields' => 'id,slug,title,content,_links.wp:featuredmedia,_embedded.wp:featuredmedia,_links.wp:term,_embedded.wp:term,acf', |
| 24 | 'acf_format' => 'standard', |
| 25 | 'per_page' => 100, |
| 26 | ]; |
| 27 | |
| 28 | /** |
| 29 | * Base URL |
| 30 | * |
| 31 | * @var string |
| 32 | */ |
| 33 | protected $base_url = 'https://integrations-catalog.surecart.com/'; |
| 34 | |
| 35 | /** |
| 36 | * Get the is plugin active attribute. |
| 37 | * |
| 38 | * @return bool |
| 39 | */ |
| 40 | public function getIsPluginActiveAttribute() { |
| 41 | if ( empty( $this->acf['plugin_file'] ) ) { |
| 42 | return false; |
| 43 | } |
| 44 | |
| 45 | return is_plugin_active( $this->acf['plugin_file'] ); |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * Get the is plugin active attribute. |
| 50 | * |
| 51 | * @return bool |
| 52 | */ |
| 53 | public function getIsThemeActiveAttribute() { |
| 54 | if ( empty( $this->acf['theme_slug'] ) ) { |
| 55 | return false; |
| 56 | } |
| 57 | |
| 58 | return wp_get_theme()->get_template() === $this->acf['theme_slug']; |
| 59 | } |
| 60 | |
| 61 | /** |
| 62 | * Get the is enabled attribute. |
| 63 | * |
| 64 | * @return bool |
| 65 | */ |
| 66 | public function getIsEnabledAttribute() { |
| 67 | if ( $this->getIsThemeActiveAttribute() ) { |
| 68 | return true; |
| 69 | } |
| 70 | if ( $this->getIsPluginActiveAttribute() ) { |
| 71 | return true; |
| 72 | } |
| 73 | |
| 74 | return false; |
| 75 | } |
| 76 | |
| 77 | /** |
| 78 | * Get the logo URL. |
| 79 | * |
| 80 | * @return string |
| 81 | */ |
| 82 | public function getLogoUrlAttribute() { |
| 83 | // svg first. |
| 84 | if ( file_exists( SURECART_PLUGIN_DIR . '/images/integrations/' . $this->slug . '.svg' ) ) { |
| 85 | return untrailingslashit( \SureCart::core()->assets()->getUrl() ) . '/images/integrations/' . $this->slug . '.svg'; |
| 86 | } |
| 87 | |
| 88 | // then png. |
| 89 | if ( file_exists( SURECART_PLUGIN_DIR . '/images/integrations/' . $this->slug . '.png' ) ) { |
| 90 | return untrailingslashit( \SureCart::core()->assets()->getUrl() ) . '/images/integrations/' . $this->slug . '.png'; |
| 91 | } |
| 92 | |
| 93 | // then fallback to the featured media. |
| 94 | return $this->_embedded['wp:featuredmedia'][0]['media_details']['sizes']['medium']['source_url'] ?? $this->_embedded['wp:featuredmedia'][0]['source_url'] ?? ''; |
| 95 | } |
| 96 | } |
| 97 |