PHP code example of arraypress / wp-money

1. Go to this page and download the library: Download arraypress/wp-money library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

arraypress / wp-money example snippets


use ArrayPress\Money\Money;

// 4999 pence, in the store's currency.
echo Money::format( 4999 );                      // £49.99
echo Money::format( 4999, [ 'currency' => 'JPY' ] );  // ¥4,999  (no decimals)

// What the customer typed, back to minor units.
$amount = Money::parse( '1,299.50', 'GBP' );     // 129950

// Would the gateway take this?
if ( ! Money::is_chargeable( $amount, 'GBP' ) ) {
    $why = Money::why_not_chargeable( $amount, 'GBP' );
}

// A sale price, marked up for a listing.
echo render_price( 3999, [ 'compare_at' => 4999 ] );