Zum Inhalt springen

Using Swift

Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.

This walkthrough takes a fresh install to a working Buy Now flow, then covers the shortcode, theming and the one developer filter.

Open WooCommerce → Swift Quick Buy, keep Enable Buy Now on, and set the label, Buy now is the default. The live preview updates as you type.

Pick where the button appears, single product, shop loops, or both, and on the product page decide whether it sits before or after add-to-cart. Set the redirect target to Checkout so Buy Now skips the cart, the usual setup.

  • Leave Empty the cart first on so Buy Now means “buy only this product now”; turn it off to keep whatever is already in the cart.
  • Turn on Respect product-page quantity if a shopper who sets quantity 3 should buy three units. Otherwise Buy Now adds one. This applies to single, simple products only.

Open a simple, in-stock product. The Buy Now button appears beside add-to-cart. Clicking it submits a nonce-protected GET form to the product permalink; Swift adds the product and redirects to your chosen target. Out-of-stock, non-purchasable and variable products show no button.

When you want Buy Now somewhere the automatic placements do not reach, a landing page, a block, a custom layout, use the shortcode:

[swift_buy_now]
[swift_buy_now id="123"]

With no attribute it targets the current product (for example inside a product template). The id attribute targets a specific product. Either way the shortcode renders nothing unless the feature is enabled and the product is a simple, in-stock, purchasable one, variable products produce no output. The shortcode button is byte-for-byte the same markup as the hooked button.

  • Single-product landing page. Redirect to checkout, leave empty-cart on, and drop [swift_buy_now id="…"] under your sales copy, one click goes straight to pay.
  • Express shortcut beside add-to-cart. Keep add-to-cart primary, place Buy Now after it, and turn empty-cart off so shoppers can still build a multi-item cart the normal way.
  • Catalogue quick buy. Enable the loop placement so high-intent shoppers can buy a simple product straight from the shop grid.

The storefront button is built on --swift-* custom properties, so you can re-theme it from your theme stylesheet without fighting markup:

.swift-buy-now-button {
--swift-accent-color: #0a7c3f; /* solid/outline fill and accent */
--swift-accent-contrast-color: #fff;
--swift-button-radius: 4px;
--swift-button-gap: 0.75em;
}

The solid and outline variants and the press animation use the accent; the theme default style inherits your theme’s own .button. Dark-scheme colours, focus-visible rings and a prefers-reduced-motion guard are built in, the press animation is suppressed when a visitor asks for reduced motion. There is no theme template-override path; the button markup lives in the plugin.

Before redirecting, Swift passes the target URL through a filter, so you can send the shopper somewhere other than the cart or checkout:

add_filter( 'wppoland_direct_checkout_redirect_url', function ( string $url, WC_Product $product, string $request_key ): string {
// e.g. route a specific product to a custom one-page checkout.
if ( $product->get_id() === 123 ) {
return home_url( '/express/' );
}
return $url;
}, 10, 3 );

The filter receives the resolved URL, the product being bought and the request key (swift_buy_now). This is the only merchant/developer-facing hook; Swift adds no shortcodes beyond [swift_buy_now].

The button is server-rendered in PHP and sits in the normal flow, so it adds no layout shift. The CSS and the optional quantity script load only when the feature is enabled, and the script is plain vanilla JavaScript in the footer with no jQuery and no external request. The admin help affordances are keyboard-operable ? buttons tied to their tooltips via aria-describedby, promoted to a native popover where supported and falling back to inline help where not.