2022 and beyond
The documentation for V2 of the PayPal API, currently the latest version, and which seems to have been cleaned up a lot over the past year or so, states the following:
shipping_preference
Displays the shipping address to the customer.
Enables the customer to choose an address on the PayPal site.
Restricts the customer from changing the address during the payment-approval process.
The possible values are:
GET_FROM_FILE. Use the customer-provided shipping address on the PayPal site.
NO_SHIPPING. Redact the shipping address from the PayPal site. Recommended for digital goods.
SET_PROVIDED_ADDRESS. Use the merchant-provided address. The customer cannot change this address on the PayPal site.
Therefore, simply adding:
"application_context" => [
"shipping_preference" => "NO_SHIPPING"
]
or if using JavaScript:
"application_context": {
"shipping_preference" => "NO_SHIPPING"
}
...to your order creation should disable any shipping options.
As an example, my PHP code to create an order using PayPal's Standard Checkout Integration (which in turn makes use of the Smart Buttons) now looks like this:
$order = $paypal->createOrder([
"intent"=> "CAPTURE",
"purchase_units"=> [
[
"amount"=> [
"currency_code" => "GBP",
"value"=> 4.99
],
'description' => 'My product description',
],
],
"application_context" => [
"shipping_preference" => "NO_SHIPPING"
]
]);