Skip to content

Conversation

@jjacquesf
Copy link

Please review

* @return int
*/
public function getShippingCost($withDiscount = false)
{
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This value is not used

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. I delete that line.

* Return full cart shipping cost
* @param $withDiscount
* @return int
*/
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why shipping cost must be in it's own separate method? It is possible to add shipping cost value during general computations using EVENT_COST_CALCULATION. If shipping cost should be based on the calculated cart cost, than probably it is possible to add event EVENT_AFTER_COST_CALCULATION and evaluate value of the cost there

Copy link
Author

@jjacquesf jjacquesf Jun 4, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I wrote two additional methods getShippingCost() and getTotal() in order to use something like this:
`
$cart = \Yii::$app->cart;

$cart->attachBehavior('percentDiscount', ['class' => 'common\components\PercentDiscount', 'ammount' => 10]);

$cart->attachBehavior('fixedShippingCost', ['class' => 'common\components\FixedShippingCost', 'ammount' => 89, 'freeSince' => 999]);

$subtotal = \Yii::$app->cart->getCost(true);

$shipping = \Yii::$app->cart->getShippingCost();

$total = \Yii::$app->cart->getTotal(true);
`

If there is a better way to get subtotal, shipping cost and total independently?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants