Blocks
8 hours ago
Concerns
7 months ago
Traits
2 months ago
Wordpress
1 year ago
AbandonedCheckout.php
1 year ago
AbandonedCheckoutProtocol.php
3 years ago
Account.php
1 year 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
7 months ago
AutoFee.php
7 months ago
AutoFeeProtocol.php
7 months ago
BalanceTransaction.php
1 year ago
Batch.php
1 month ago
Brand.php
5 months ago
BulkAction.php
2 years ago
Bump.php
1 year ago
BundleItem.php
1 month ago
BuyLink.php
2 years ago
CancellationAct.php
1 year ago
CancellationReason.php
3 years ago
Charge.php
11 months ago
Checkout.php
1 month ago
Click.php
1 year ago
Collection.php
4 months ago
CommissionStructure.php
2 years ago
Component.php
6 months ago
Coupon.php
4 months ago
Customer.php
2 months ago
CustomerLink.php
4 years ago
CustomerNotificationProtocol.php
4 years ago
CustomerPortalProtocol.php
1 year ago
DatabaseModel.php
4 months ago
Discount.php
1 year ago
DisplayCurrency.php
1 year ago
Dispute.php
11 months ago
Download.php
4 years ago
Event.php
4 years ago
Export.php
2 years ago
ExternalApiModel.php
4 months ago
Fee.php
1 year ago
Form.php
8 hours ago
Fulfillment.php
1 week ago
FulfillmentItem.php
1 year ago
GalleryItem.php
11 months ago
GalleryItemAttachment.php
6 months ago
GalleryItemImageAttachment.php
4 months ago
GalleryItemMedia.php
1 year ago
GalleryItemProductMedia.php
2 months ago
GalleryItemVideoAttachment.php
4 months ago
Import.php
7 months ago
ImportRow.php
3 months ago
IncomingWebhook.php
1 year ago
Integration.php
2 years ago
IntegrationCatalog.php
1 month ago
Invoice.php
1 year ago
License.php
1 year ago
LineItem.php
1 month ago
ManualPaymentMethod.php
1 year ago
Media.php
2 months ago
Model.php
1 month ago
ModelInterface.php
4 years ago
Order.php
2 months ago
OrderProtocol.php
4 years ago
ParcelTemplate.php
1 week ago
PaymentFailure.php
1 year ago
PaymentInstrument.php
3 months ago
PaymentIntent.php
1 year ago
PaymentMethod.php
1 year ago
Payout.php
1 year ago
PayoutGroup.php
2 years ago
Period.php
1 year ago
PlatformFee.php
1 year ago
PortalSession.php
4 years ago
Price.php
8 months ago
Processor.php
1 year ago
Product.php
2 weeks ago
ProductCollection.php
1 year ago
ProductCollectionImport.php
7 months ago
ProductGroup.php
1 year ago
ProductImport.php
7 months ago
ProductMedia.php
6 months ago
Promotion.php
1 year ago
ProvisionalAccount.php
3 months ago
Purchase.php
2 years ago
Referral.php
1 year ago
ReferralItem.php
2 years ago
Refund.php
1 year ago
RefundItem.php
1 year ago
RegisteredWebhook.php
3 months ago
ReturnItem.php
2 years ago
ReturnReason.php
2 years ago
ReturnRequest.php
1 year ago
Review.php
6 months ago
ReviewProtocol.php
6 months ago
RuleSchema.php
7 months ago
ServiceFee.php
1 year ago
Shipment.php
1 week ago
ShippingChoice.php
1 year ago
ShippingMethod.php
3 years ago
ShippingProfile.php
3 years ago
ShippingProtocol.php
3 years ago
ShippingProviderType.php
1 week ago
ShippingRate.php
3 years ago
ShippingZone.php
3 years ago
Statistic.php
4 years ago
Subscription.php
2 months ago
SubscriptionProtocol.php
4 years ago
Swap.php
1 year 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
4 weeks ago
Variant.php
1 month ago
VariantOption.php
2 years ago
VariantOptionValue.php
1 year ago
VariantValue.php
2 years ago
VerificationCode.php
3 years ago
Warehouse.php
1 week ago
Webhook.php
1 year ago
WebhookRegistration.php
2 years ago
ShippingProviderType.php
81 lines
| 1 | <?php |
| 2 | |
| 3 | namespace SureCart\Models; |
| 4 | |
| 5 | /** |
| 6 | * ShippingProviderType model. |
| 7 | */ |
| 8 | class ShippingProviderType extends Model { |
| 9 | /** |
| 10 | * Rest API endpoint |
| 11 | * |
| 12 | * @var string |
| 13 | */ |
| 14 | protected $endpoint = 'shipping_providers'; |
| 15 | |
| 16 | /** |
| 17 | * Object name |
| 18 | * |
| 19 | * @var string |
| 20 | */ |
| 21 | protected $object_name = 'shipping_provider'; |
| 22 | |
| 23 | /** |
| 24 | * Get the carrier accounts connected to a shipping provider. |
| 25 | * |
| 26 | * This is a list sub-resource, not a single fillable model, so we return |
| 27 | * the raw API response as-is. |
| 28 | * |
| 29 | * @param string $id Model id. |
| 30 | * @return array|\WP_Error |
| 31 | */ |
| 32 | protected function carrierAccounts( $id = null ) { |
| 33 | if ( $id ) { |
| 34 | $this->setAttribute( 'id', $id ); |
| 35 | } |
| 36 | |
| 37 | if ( empty( $this->attributes['id'] ) ) { |
| 38 | return new \WP_Error( 'not_saved', __( 'Please provide a shipping provider.', 'surecart' ) ); |
| 39 | } |
| 40 | |
| 41 | return $this->makeRequest( |
| 42 | [ |
| 43 | 'method' => 'GET', |
| 44 | 'query' => $this->query, |
| 45 | ], |
| 46 | $this->endpoint . '/' . rawurlencode( $this->attributes['id'] ) . '/carrier_accounts' |
| 47 | ); |
| 48 | } |
| 49 | |
| 50 | /** |
| 51 | * Get the carrier parcel templates available to a shipping provider. |
| 52 | * |
| 53 | * Carrier-defined packages (USPS Flat Rate boxes, FedEx paks, and so on). |
| 54 | * Like carrier accounts this is a read-only list sub-resource, so the raw |
| 55 | * API response is returned as-is. |
| 56 | * |
| 57 | * Availability differs between test and live mode providers, which is why |
| 58 | * the catalogue hangs off a provider rather than the account. |
| 59 | * |
| 60 | * @param string $id Model id. |
| 61 | * @return array|\WP_Error |
| 62 | */ |
| 63 | protected function carrierParcelTemplates( $id = null ) { |
| 64 | if ( $id ) { |
| 65 | $this->setAttribute( 'id', $id ); |
| 66 | } |
| 67 | |
| 68 | if ( empty( $this->attributes['id'] ) ) { |
| 69 | return new \WP_Error( 'not_saved', __( 'Please provide a shipping provider.', 'surecart' ) ); |
| 70 | } |
| 71 | |
| 72 | return $this->makeRequest( |
| 73 | [ |
| 74 | 'method' => 'GET', |
| 75 | 'query' => $this->query, |
| 76 | ], |
| 77 | $this->endpoint . '/' . rawurlencode( $this->attributes['id'] ) . '/carrier_parcel_templates' |
| 78 | ); |
| 79 | } |
| 80 | } |
| 81 |