Automattic\WooCommerce\Internal\OrderReviews
Endpoint::get_url
Build the public, tokenised URL for an order's review-order page.
Method of the class: Endpoint{}
Hooks from the method
Returns
String.
Usage
$result = Endpoint::get_url( $order ): string;
- $order(WC_Order) (required)
- Order to build the URL for.
Endpoint::get_url() Endpoint::get url code WC 10.8.1
public static function get_url( WC_Order $order ): string {
$page_id = (int) wc_get_page_id( self::PAGE_KEY );
$permalink = (string) ( $page_id > 0 ? get_permalink( $page_id ) : '' );
if ( '' === $permalink ) {
$url = '';
} elseif ( false === strpos( $permalink, '?' ) ) {
// Pretty permalinks: append the order id as a path segment.
$url = trailingslashit( $permalink ) . (string) $order->get_id() . '/';
$url = add_query_arg( 'key', $order->get_order_key(), $url );
} else {
// Plain permalinks: page permalink is /?page_id=NNN, so add the
// order id as a query var rather than munging the path.
$url = add_query_arg(
array(
self::QUERY_VAR => (string) $order->get_id(),
'key' => $order->get_order_key(),
),
$permalink
);
}
/**
* Filter the Review Order URL that the review-request email links to.
*
* @since 10.8.0
*
* @param string $url The review-order URL.
* @param WC_Order $order The order object.
*/
return (string) apply_filters( 'woocommerce_review_order_url', $url, $order );
}