L
L
lookingfor22020-05-24 23:09:54
MODX
lookingfor2, 2020-05-24 23:09:54

Price per item?

I need the price to be indicated depending on the quantity of goods I
5ecad402ba410496064859.png

wrote such a plugin

<?php
switch ($modx->event->name) {
      case 'msOnChangeInCart':
        //Доступные переменные - $product, $count, $options, $cart
         
         $tmp = $cart->get();
         $countAll = $tmp[$key]['count'];
         $priceAll = $tmp[$key]['price'];
         $tmp[$key]['price'] = $countAll * $priceAll;
         $cart->set($tmp);
         $modx->event->output($cart);
         break;
         
    }


But this is how the price for the entire basket changes, not the price of a specific product
And in general, I need to add the price per unit of goods to the constant, and when changing, multiply the quantity by the constant ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
ThunderCat, 2020-05-24
@ThunderCat

where did $key come from? Make a vardump of your $tmp and see what and how it lies there, the business is ...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question