1. MarineLukeH

    MarineLukeH - Oct 29, 2015 New Member VIP Member

    Credit
    Point
    I've tried a couple of times to ask this via the ticket system.

    Can someone tell me if it is possible to randomize the images shown, rather than the order of purchase. If people have 10+ images purchased, it seems pointless than only the last few are shown as I can't show all 10.

    Regards
    Luke
     
    Loading...
  2. Brivium

    Brivium - Oct 29, 2015 XenForo Services Staff Member

    Credit
    Point
    Dear Luke,

    You can do this by open and replace all content of file library/Brivium/StoreProduct/ImageSignature/EventListeners/Helpers.php with
    Code:
    <?php
    class Brivium_StoreProduct_ImageSignature_EventListeners_Helpers extends XenForo_Template_Helper_Core
    {
        protected static $_productsImageSignatures = array();
    
        /**
         * Sets the product image signature.
         *
         * @param array $productsImageSignatures
         */
        public static function setProductImageSignatures(array $productsImageSignatures)
        {
            self::$_productsImageSignatures = $productsImageSignatures;
        }
        /**
         * Helper to get the user title for the specified user.
         *
         * @param array $user
         * @param boolean $allowCustomTitle Allows the user title to come from the custom title
         *
         * @return string
         */
        public static function helperUserImageSignature($user)
        {
            if(!empty($user['user_id'])){
    
                $storeModel = self::_getModelFromCache('Brivium_Store_Model_Store');
                if(!empty($user['user_id']) && isset(self::$_productsImageSignatures[$user['user_id']])){
                    $purchaseList = self::$_productsImageSignatures[$user['user_id']];
                    $imageSignature = array();
                    if($purchaseList){
                        $number = XenForo_Application::get('options')->BRSIS_numberImage;
                        $count = 0;
                        foreach($purchaseList AS $product){
                            $product = XenForo_Application::get('brsProducts')->$product;
                            if($product){
                                if($count<$number || $number == 0){
                                    $imageSignature[$product['product_id']] = $product;
                                    $count++;
                                }
                            }
                        }
    
                        if(!empty($imageSignature)){
                            $keys = array_keys($imageSignature);
                            shuffle($keys);
                            $new = array();
                            foreach($keys as $key) {
                                $new[$key] = $imageSignature[$key];
                            }
                        }
                    }
    
                    $imageSignature = $new;
                    return $imageSignature;
                }
            }
            return null;
        }
    
    }
    ?>
    Regards,
     
    #2
  3. MarineLukeH

    MarineLukeH - Oct 30, 2015 New Member VIP Member

    Credit
    Point
    That works a treat, many thanks for help and the fabulous addons!
     
    #3