Bestseller Counts > only for only paid products

Hi all,



our version CS 2.0.15 and we use the Bestsellers addon.



We like to fill bestsellers list only with “real” paid products not only the orders. If there a user which ordering a product but the payment process is not successful it will be displayed in the bestsellers list. But the order is broken. Addon count orders, not completed orders.



How can I change that the amount of product oders depends from a defined order status. We’ll register a product for bestsellers only if the order status ‘P’ active but not before.



My try to change the values in “addons/bestsellers/func.php” was not successful.


    if ($order_statuses[$status_to]['inventory'] == 'D' && $order_statuses[$status_from]['inventory'] == 'I') {<br />
        $increase = true;<br />
    } elseif ($order_statuses[$status_to]['inventory'] == 'I' && $order_statuses[$status_from]['inventory'] == 'D') {<br />
        $increase = false;<br />
    } else {<br />
        return true;<br />
    }
```<br />
<br />
Anyone hint for me please? I mean it could be possible. Thanks.<br />
<br />
Best regards,<br />
Michael

The code would have to be completely changed to accomplish your goal. The current code is not stating the order status itself but D-decrease/I-increase in the inventory.

Thank you for notes. You’re right wrong code area. I’m sometimes blind…inventory. :shock:



I tought there is anywhere a code area/switch to define “Sales amount” + 1 only if a order in a defined status. In our case ‘P’. Not before. Do you see anyone idea or file which we can try to edit in our mind?



Thanks and best regards,

Michael

After thinking about it further you may be able to do something like below. I am not sure “status” will work. It may be “order_status”. Also you might want to use “C” instead of “P”.



```php if ($order_statuses[$status_to][‘status’] == ‘O’ && $order_statuses[$status_from][‘status’] == ‘P’) {

$increase = true;

} elseif ($order_statuses[$status_to][‘status’] == ‘P’ && $order_statuses[$status_from][‘status’] == ‘O’) {

$increase = false;

} else {

return true;

} ```

Great suggestion, it works! Our final status is ‘P’ we offer only download products. So here my code block to control the real sales. Only a switch to ‘P’ = count order products. We ignore ‘C’ in our internal workflow.



```php # disable old product count switch

#if ($order_statuses[$status_to][‘inventory’] == ‘D’ && $order_statuses[$status_from][‘inventory’] == ‘I’) {

# $increase = true;

#} elseif ($order_statuses[$status_to][‘inventory’] == ‘I’ && $order_statuses[$status_from][‘inventory’] == ‘D’) {

# $increase = false;

#} else {

# return true;

#}



# new product count switch > order status … to ‘P’ = plus | order status ‘P’ to … = minus

if ($order_statuses[$status_to][‘status’] == ‘P’ && $order_statuses[$status_from][‘status’] == ‘O’) {

$increase = true;

} elseif ($order_statuses[$status_to][‘status’] == ‘P’ && $order_statuses[$status_from][‘status’] == ‘F’) {

$increase = true;

} elseif ($order_statuses[$status_to][‘status’] == ‘P’ && $order_statuses[$status_from][‘status’] == ‘D’) {

$increase = true;

} elseif ($order_statuses[$status_to][‘status’] == ‘P’ && $order_statuses[$status_from][‘status’] == ‘I’) {

$increase = true;

} elseif ($order_statuses[$status_to][‘status’] == ‘P’ && $order_statuses[$status_from][‘status’] == ‘B’) {

$increase = true;



} elseif ($order_statuses[$status_to][‘status’] == ‘O’ && $order_statuses[$status_from][‘status’] == ‘P’) {

$increase = false;

} elseif ($order_statuses[$status_to][‘status’] == ‘F’ && $order_statuses[$status_from][‘status’] == ‘P’) {

$increase = false;

} elseif ($order_statuses[$status_to][‘status’] == ‘D’ && $order_statuses[$status_from][‘status’] == ‘P’) {

$increase = false;

} elseif ($order_statuses[$status_to][‘status’] == ‘I’ && $order_statuses[$status_from][‘status’] == ‘P’) {

$increase = false;

} elseif ($order_statuses[$status_to][‘status’] == ‘B’ && $order_statuses[$status_from][‘status’] == ‘P’) {

$increase = false;

} else {

return true;

} ```



It’s tested and published. I think this issue is fixed. Thanks again!



Best regards,

Michael

Glad it worked out for you. It looks like I have it backwards. :stuck_out_tongue: