Ejemplo n.º 1
0
    $transaction->reset();
} else {
    // Otherwise create a new transaction
    $transaction = new MoodecTransaction();
}
// Set the transactionId in the cart to that of the transaction
// We do this in case the transaction reset created a new transaction
// Or, to add the transaction id to the cart if one didn't already exist
$cart->set_transaction_id($transaction->get_id());
// We need to add all the products in the cart to the transaction
foreach ($cart->get() as $pID => $vID) {
    // Get the product in the cart
    $product = local_moodec_get_product($pID);
    // Add the product to the transaction, relative to variation
    if ($product->get_type() === PRODUCT_TYPE_VARIABLE) {
        $transaction->add($pID, $product->get_variation($vID)->get_price(), $vID);
    } else {
        $transaction->add($pID, $product->get_price());
    }
}
echo $OUTPUT->header();
?>

<h1 class="page__title"><?php 
echo get_string('checkout_title', 'local_moodec');
?>
</h1>

<?php 
// Output cart review
echo $renderer->cart_review($cart, $removedProducts);