idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
54,400
public function editPriceRule ( $ rule_id = null ) { $ this -> setPriceRule ( $ rule_id ) ; $ this -> setTitleEditPriceRule ( ) ; $ this -> setBreadcrumbEditPriceRule ( ) ; $ this -> setData ( 'price_rule' , $ this -> data_rule ) ; $ this -> setData ( 'types' , $ this -> price_rule -> getTypes ( ) ) ; $ this -> setData ( 'triggers' , $ this -> getTriggersPriceRule ( ) ) ; $ this -> setData ( 'currencies' , $ this -> getCurrenciesPriceRule ( ) ) ; $ this -> submitEditPriceRule ( ) ; $ this -> outputEditPriceRule ( ) ; }
Displays the price rule edit form
54,401
protected function getTriggersPriceRule ( ) { $ list = ( array ) $ this -> trigger -> getList ( ) ; foreach ( $ list as & $ item ) { if ( empty ( $ item [ 'status' ] ) ) { $ item [ 'name' ] .= ' (' . $ this -> lower ( $ this -> text ( 'Disabled' ) ) . ')' ; } } return $ list ; }
Returns an array of enabled triggers
54,402
protected function setPriceRule ( $ rule_id ) { $ this -> data_rule = array ( ) ; if ( is_numeric ( $ rule_id ) ) { $ this -> data_rule = $ this -> price_rule -> get ( $ rule_id ) ; if ( empty ( $ this -> data_rule ) ) { $ this -> outputHttpStatus ( 404 ) ; } } }
Returns an array of price rule data
54,403
protected function submitEditPriceRule ( ) { if ( $ this -> isPosted ( 'delete' ) ) { $ this -> deletePriceRule ( ) ; } else if ( $ this -> isPosted ( 'save' ) && $ this -> validateEditPriceRule ( ) ) { if ( isset ( $ this -> data_rule [ 'price_rule_id' ] ) ) { $ this -> updatePriceRule ( ) ; } else { $ this -> addPriceRule ( ) ; } } }
Handles a submitted price rule
54,404
protected function validateEditPriceRule ( ) { $ this -> setSubmitted ( 'price_rule' , null , false ) ; $ this -> setSubmittedBool ( 'status' ) ; $ this -> setSubmitted ( 'update' , $ this -> data_rule ) ; $ this -> validateComponent ( 'price_rule' ) ; return ! $ this -> hasErrors ( ) ; }
Validates a submitted price rule
54,405
protected function deletePriceRule ( ) { $ this -> controlAccess ( 'price_rule_delete' ) ; if ( $ this -> price_rule -> delete ( $ this -> data_rule [ 'price_rule_id' ] ) ) { $ this -> redirect ( 'admin/sale/price' , $ this -> text ( 'Price rule has been deleted' ) , 'success' ) ; } $ this -> redirect ( '' , $ this -> text ( 'Price rule has not been deleted' ) , 'warning' ) ; }
Deletes a price rule
54,406
protected function addPriceRule ( ) { $ this -> controlAccess ( 'price_rule_add' ) ; if ( $ this -> price_rule -> add ( $ this -> getSubmitted ( ) ) ) { $ this -> redirect ( 'admin/sale/price' , $ this -> text ( 'Price rule has been added' ) , 'success' ) ; } $ this -> redirect ( '' , $ this -> text ( 'Price rule has not been added' ) , 'warning' ) ; }
Adds a new price rule
54,407
protected function setTitleEditPriceRule ( ) { if ( isset ( $ this -> data_rule [ 'price_rule_id' ] ) ) { $ title = $ this -> text ( 'Edit %name' , array ( '%name' => $ this -> data_rule [ 'name' ] ) ) ; } else { $ title = $ this -> text ( 'Add price rule' ) ; } $ this -> setTitle ( $ title ) ; }
Sets title on the edit price rule page
54,408
protected function setBreadcrumbEditPriceRule ( ) { $ breadcrumbs = array ( ) ; $ breadcrumbs [ ] = array ( 'url' => $ this -> url ( 'admin' ) , 'text' => $ this -> text ( 'Dashboard' ) ) ; $ breadcrumbs [ ] = array ( 'text' => $ this -> text ( 'Price rules' ) , 'url' => $ this -> url ( 'admin/sale/price' ) ) ; $ this -> setBreadcrumbs ( $ breadcrumbs ) ; }
Sets breadcrumbs on the edit price rule page
54,409
public function price ( array $ values ) { if ( count ( $ values ) != 1 ) { return $ this -> translation -> text ( '@field has invalid value' , array ( '@field' => $ this -> translation -> text ( 'Condition' ) ) ) ; } $ components = array_map ( 'trim' , explode ( '|' , reset ( $ values ) ) ) ; if ( count ( $ components ) > 2 ) { return $ this -> translation -> text ( '@field has invalid value' , array ( '@field' => $ this -> translation -> text ( 'Condition' ) ) ) ; } if ( ! is_numeric ( $ components [ 0 ] ) ) { return $ this -> translation -> text ( '@field must be numeric' , array ( '@field' => $ this -> translation -> text ( 'Price' ) ) ) ; } if ( strlen ( $ components [ 0 ] ) > 8 ) { return $ this -> translation -> text ( '@field must not be longer than @max characters' , array ( '@max' => 8 , '@field' => $ this -> translation -> text ( 'Price' ) ) ) ; } if ( empty ( $ components [ 1 ] ) ) { $ components [ 1 ] = $ this -> currency -> getDefault ( ) ; } $ currency = $ this -> currency -> get ( $ components [ 1 ] ) ; if ( empty ( $ currency ) ) { return $ this -> translation -> text ( '@name is unavailable' , array ( '@name' => $ this -> translation -> text ( 'Currency' ) ) ) ; } return true ; }
Validates a price condition
54,410
public function get ( $ state_id ) { $ result = & gplcart_static ( "state.get.$state_id" ) ; if ( isset ( $ result ) ) { return $ result ; } $ this -> hook -> attach ( 'state.get.before' , $ state_id , $ result , $ this ) ; if ( isset ( $ result ) ) { return $ result ; } $ result = $ this -> db -> fetch ( 'SELECT * FROM state WHERE state_id=?' , array ( $ state_id ) ) ; $ this -> hook -> attach ( 'state.get.after' , $ state_id , $ result , $ this ) ; return $ result ; }
Loads a country state from the database
54,411
protected function setInstanceProperties ( ) { $ this -> hook = $ this -> getInstance ( 'gplcart\\core\\Hook' ) ; $ this -> config = $ this -> getInstance ( 'gplcart\\core\\Config' ) ; $ this -> route = $ this -> getInstance ( 'gplcart\\core\\CliRoute' ) ; $ this -> cli = $ this -> getInstance ( 'gplcart\\core\\helpers\Cli' ) ; $ this -> user = $ this -> getInstance ( 'gplcart\\core\\models\\User' ) ; $ this -> language = $ this -> getInstance ( 'gplcart\\core\\models\\Language' ) ; $ this -> validator = $ this -> getInstance ( 'gplcart\\core\\models\\Validator' ) ; $ this -> translation = $ this -> getInstance ( 'gplcart\\core\\models\\Translation' ) ; }
Sets class instance properties
54,412
public function setLanguage ( $ code = null ) { if ( ! isset ( $ code ) ) { $ code = $ this -> config -> get ( 'cli_langcode' , '' ) ; } $ this -> langcode = $ code ; $ this -> translation -> set ( $ code , null ) ; return $ this ; }
Sets the current language
54,413
protected function setUser ( ) { $ this -> uid = $ this -> getParam ( 'u' , null ) ; if ( isset ( $ this -> uid ) ) { $ this -> current_user = $ this -> user -> get ( $ this -> uid ) ; if ( empty ( $ this -> current_user [ 'status' ] ) ) { $ this -> errorAndExit ( $ this -> text ( 'No access' ) ) ; } } }
Sets the current user from the command using - u option
54,414
protected function setRouteProperties ( ) { $ this -> current_route = $ this -> route -> get ( ) ; $ this -> command = $ this -> current_route [ 'command' ] ; $ this -> params = gplcart_array_trim ( $ this -> current_route [ 'params' ] , true ) ; }
Sets route properties
54,415
protected function controlAccess ( $ permission ) { if ( isset ( $ this -> uid ) && ! $ this -> user -> access ( $ permission , $ this -> uid ) ) { $ this -> errorAndExit ( $ this -> text ( 'No access' ) ) ; } }
Control access to the route
54,416
protected function controlOptions ( ) { $ allowed = array ( ) ; if ( ! empty ( $ this -> current_route [ 'options' ] ) ) { foreach ( array_keys ( $ this -> current_route [ 'options' ] ) as $ options ) { foreach ( explode ( ',' , $ options ) as $ option ) { $ allowed [ trim ( trim ( $ option , '-' ) ) ] = true ; } } } $ submitted = $ this -> getOptions ( ) ; if ( ! empty ( $ submitted ) && ! array_intersect_key ( $ submitted , $ allowed ) ) { $ this -> errorAndExit ( $ this -> text ( 'Unsupported command options' ) ) ; } }
Controls supported command options
54,417
protected function controlArguments ( ) { if ( ! empty ( $ this -> current_route [ 'arguments' ] ) ) { $ submitted = $ this -> getArguments ( ) ; if ( ! empty ( $ submitted ) && ! array_intersect_key ( $ submitted , $ this -> current_route [ 'arguments' ] ) ) { $ this -> errorAndExit ( $ this -> text ( 'Unsupported command arguments' ) ) ; } } }
Controls supported command arguments
54,418
protected function controlRouteAccess ( ) { if ( ! $ this -> config -> get ( 'cli_status' , true ) ) { $ this -> errorAndExit ( $ this -> text ( 'No access' ) ) ; } $ this -> controlAccess ( 'cli' ) ; if ( isset ( $ this -> current_route [ 'access' ] ) ) { $ this -> controlAccess ( $ this -> current_route [ 'access' ] ) ; } }
Controls access to the current route
54,419
public function setSubmittedMapped ( array $ map , $ params = null , array $ default = array ( ) ) { $ mapped = $ this -> mapParams ( $ map , $ params ) ; $ merged = gplcart_array_merge ( $ default , $ mapped ) ; return $ this -> setSubmitted ( null , $ merged ) ; }
Sets an array of submitted mapped data
54,420
public function setSubmitted ( $ key , $ data ) { if ( isset ( $ key ) ) { gplcart_array_set ( $ this -> submitted , $ key , $ data ) ; return $ this -> submitted ; } return $ this -> submitted = ( array ) $ data ; }
Sets a submitted data
54,421
public function getParam ( $ key = null , $ default = null ) { if ( ! isset ( $ key ) ) { return $ this -> params ; } foreach ( ( array ) $ key as $ k ) { if ( isset ( $ this -> params [ $ k ] ) ) { return $ this -> params [ $ k ] ; } } return $ default ; }
Returns a single parameter value
54,422
public function isError ( $ key = null ) { $ value = $ this -> getError ( $ key ) ; return is_array ( $ value ) ? ! empty ( $ value ) : isset ( $ value ) ; }
Whether a error exists
54,423
public function getError ( $ key = null ) { if ( isset ( $ key ) ) { return gplcart_array_get ( $ this -> errors , $ key ) ; } return $ this -> errors ; }
Returns a single error or an array of all defined errors
54,424
public function errors ( $ exit_on_error = false ) { if ( ! empty ( $ this -> errors ) ) { foreach ( gplcart_array_flatten ( $ this -> errors ) as $ error ) { $ this -> error ( $ error ) ; } $ this -> errors = array ( ) ; if ( $ exit_on_error ) { $ this -> abort ( 1 ) ; } } }
Print and clear up all existing errors
54,425
public function mapParams ( array $ map , $ params = null ) { if ( ! isset ( $ params ) ) { $ params = $ this -> params ; } $ mapped = array ( ) ; foreach ( $ params as $ key => $ value ) { if ( isset ( $ map [ $ key ] ) && is_string ( $ map [ $ key ] ) ) { gplcart_array_set ( $ mapped , $ map [ $ key ] , $ value ) ; } } return $ mapped ; }
Map the command line parameters to an array of submitted data to be passed to validators
54,426
public function isValidInput ( $ input , $ field , $ handler_id ) { $ this -> setSubmitted ( $ field , $ input ) ; return $ this -> validateComponent ( $ handler_id , array ( 'field' => $ field ) ) === true ; }
Whether the user input passed the field validation
54,427
protected function validatePrompt ( $ field , $ label , $ validator , $ default = null ) { $ input = $ this -> prompt ( $ label , $ default ) ; if ( ! $ this -> isValidInput ( $ input , $ field , $ validator ) ) { $ this -> errors ( ) ; $ this -> validatePrompt ( $ field , $ label , $ validator , $ default ) ; } }
Validates a user input from prompt
54,428
protected function validateMenu ( $ field , $ label , $ validator , array $ options , $ default = null ) { $ input = $ this -> menu ( $ options , $ default , $ label ) ; if ( ! $ this -> isValidInput ( $ input , $ field , $ validator ) ) { $ this -> errors ( ) ; $ this -> validateMenu ( $ field , $ label , $ validator , $ options , $ default ) ; } }
Validates a chosen menu option
54,429
public function outputHelp ( $ command = null ) { $ help_options = $ this -> config -> get ( 'cli_help_option' , 'h' ) ; if ( isset ( $ command ) || $ this -> getParam ( $ help_options ) ) { if ( ! isset ( $ command ) ) { $ command = $ this -> command ; } $ aliases = $ this -> route -> getAliases ( ) ; if ( isset ( $ aliases [ $ command ] ) ) { $ command = $ aliases [ $ command ] ; } $ routes = $ this -> route -> getList ( ) ; if ( empty ( $ routes [ $ command ] ) ) { $ this -> errorAndExit ( $ this -> text ( 'Unknown command' ) ) ; } $ this -> printHelpText ( $ routes [ $ command ] ) ; $ this -> output ( ) ; } }
Output help for a certain command or the current command if a help option is specified
54,430
protected function printHelpText ( array $ command ) { $ shown = false ; if ( ! empty ( $ command [ 'description' ] ) ) { $ shown = true ; $ this -> line ( $ this -> text ( $ command [ 'description' ] ) ) ; } if ( ! empty ( $ command [ 'usage' ] ) ) { $ shown = true ; $ this -> line ( ) -> line ( $ this -> text ( 'Usage:' ) ) ; foreach ( $ command [ 'usage' ] as $ usage ) { $ this -> line ( $ usage ) ; } } if ( ! empty ( $ command [ 'options' ] ) ) { $ shown = true ; $ this -> line ( ) -> line ( $ this -> text ( 'Options:' ) ) ; foreach ( $ command [ 'options' ] as $ name => $ description ) { $ vars = array ( '@option' => $ name , '@description' => $ this -> text ( $ description ) ) ; $ this -> line ( $ this -> text ( ' @option @description' , $ vars ) ) ; } } if ( ! $ shown ) { $ this -> line ( $ this -> text ( 'No help found for the command' ) ) ; } }
Print command help text
54,431
public function selectLanguage ( $ langcode = null ) { $ languages = array ( ) ; foreach ( $ this -> language -> getList ( ) as $ code => $ language ) { if ( $ code === 'en' || is_file ( $ this -> translation -> getFile ( $ code ) ) ) { $ languages [ $ code ] = $ language [ 'name' ] ; } } if ( count ( $ languages ) < 2 && ! isset ( $ langcode ) ) { return null ; } if ( isset ( $ langcode ) ) { $ selected = $ langcode ; } else { $ selected = $ this -> menu ( $ languages , 'en' , $ this -> text ( 'Language (enter a number)' ) ) ; } if ( empty ( $ languages [ $ selected ] ) ) { $ this -> error ( $ this -> text ( 'Invalid language' ) ) ; $ this -> selectLanguage ( ) ; } else { $ this -> langcode = ( string ) $ selected ; $ this -> translation -> set ( $ this -> langcode , null ) ; $ this -> config -> set ( 'cli_langcode' , $ this -> langcode ) ; } return $ this -> langcode ; }
Shows language selector and validates user s input
54,432
public function getTree ( array $ options ) { $ tree = & gplcart_static ( gplcart_array_hash ( array ( 'category.tree' => $ options ) ) ) ; if ( isset ( $ tree ) ) { return $ tree ; } $ list = ( array ) $ this -> getList ( $ options ) ; $ tree = $ this -> prepareTree ( $ list , $ options ) ; $ this -> hook -> attach ( 'category.tree' , $ tree , $ this ) ; return $ tree ; }
Returns an array of categories with parent categories set
54,433
public function add ( array $ data ) { $ result = null ; $ this -> hook -> attach ( 'category.add.before' , $ data , $ result , $ this ) ; if ( isset ( $ result ) ) { return ( int ) $ result ; } $ result = $ data [ 'category_id' ] = $ this -> db -> insert ( 'category' , $ data ) ; $ this -> setTranslations ( $ data , $ this -> translation_entity , 'category' , false ) ; $ this -> setImages ( $ data , $ this -> file , 'category' ) ; $ this -> setAlias ( $ data , $ this -> alias , 'category' , false ) ; $ this -> hook -> attach ( 'category.add.after' , $ data , $ result , $ this ) ; return ( int ) $ result ; }
Adds a category
54,434
protected function deleteLinked ( $ category_id ) { $ this -> db -> delete ( 'category_translation' , array ( 'category_id' => $ category_id ) ) ; $ this -> db -> delete ( 'file' , array ( 'entity' => 'category' , 'entity_id' => $ category_id ) ) ; $ this -> db -> delete ( 'alias' , array ( 'entity' => 'category' , 'entity_id' => $ category_id ) ) ; }
Delete all database records related to the category ID
54,435
protected function prepareTree ( array $ categories , array $ options ) { $ tree = array ( ) ; $ parents_tree = array ( ) ; $ children_tree = array ( ) ; $ categories_tree = array ( ) ; $ parent = isset ( $ options [ 'parent_id' ] ) ? ( int ) $ options [ 'parent_id' ] : 0 ; foreach ( $ categories as $ category ) { $ children_tree [ $ category [ 'parent_id' ] ] [ ] = $ category [ 'category_id' ] ; $ parents_tree [ $ category [ 'category_id' ] ] [ ] = $ category [ 'parent_id' ] ; $ categories_tree [ $ category [ 'category_id' ] ] = $ category ; } $ max_depth = isset ( $ options [ 'depth' ] ) ? ( int ) $ options [ 'depth' ] : count ( $ children_tree ) ; $ process_parents = array ( ) ; $ process_parents [ ] = $ parent ; while ( count ( $ process_parents ) ) { $ parent = array_pop ( $ process_parents ) ; $ depth = count ( $ process_parents ) ; if ( $ max_depth <= $ depth || empty ( $ children_tree [ $ parent ] ) ) { continue ; } $ has_children = false ; $ child = current ( $ children_tree [ $ parent ] ) ; do { if ( empty ( $ child ) ) { break ; } $ category = $ categories_tree [ $ child ] ; $ category [ 'depth' ] = $ depth ; $ category [ 'parents' ] = $ parents_tree [ $ category [ 'category_id' ] ] ; $ tree [ $ category [ 'category_id' ] ] = $ category ; if ( ! empty ( $ children_tree [ $ category [ 'category_id' ] ] ) ) { $ has_children = true ; $ process_parents [ ] = $ parent ; $ process_parents [ ] = $ category [ 'category_id' ] ; reset ( $ categories_tree [ $ category [ 'category_id' ] ] ) ; next ( $ children_tree [ $ parent ] ) ; break ; } } while ( $ child = next ( $ children_tree [ $ parent ] ) ) ; if ( ! $ has_children ) { reset ( $ children_tree [ $ parent ] ) ; } } return $ tree ; }
Create a tree structure from an array of categories
54,436
public function listReportShipping ( ) { $ this -> setTitleListReportShipping ( ) ; $ this -> setBreadcrumbListReportShipping ( ) ; $ this -> setFilterListReportShipping ( ) ; $ this -> setPagerListReportShipping ( ) ; $ this -> setData ( 'methods' , ( array ) $ this -> getListReportShipping ( ) ) ; $ this -> outputListReportShipping ( ) ; }
Displays the shipping method overview page
54,437
protected function getListReportShipping ( $ count = false ) { $ list = $ this -> shipping -> getList ( ) ; $ allowed = $ this -> getAllowedFiltersReportShipping ( ) ; $ this -> filterList ( $ list , $ allowed , $ this -> query_filter ) ; $ this -> sortList ( $ list , $ allowed , $ this -> query_filter , array ( 'id' => 'asc' ) ) ; if ( $ count ) { return count ( $ list ) ; } $ this -> limitList ( $ list , $ this -> data_limit ) ; return $ list ; }
Returns an array of shipping methods or counts them
54,438
protected function validateWizardInstall ( ) { $ this -> selectLanguage ( ) ; $ this -> validateRequirementsInstall ( ) ; $ this -> validateInstallerInstall ( ) ; $ this -> validatePrompt ( 'store.title' , $ this -> text ( 'Store title' ) , 'install' , 'GPLCart' ) ; $ this -> validatePrompt ( 'user.email' , $ this -> text ( 'E-mail' ) , 'install' ) ; $ this -> validatePrompt ( 'user.password' , $ this -> text ( 'Password' ) , 'install' ) ; $ this -> validatePrompt ( 'store.host' , $ this -> text ( 'Host' ) , 'install' , 'localhost' ) ; $ this -> validatePrompt ( 'store.basepath' , $ this -> text ( 'Installation subdirectory' ) , 'install' , '' ) ; $ this -> validateInputDbInstall ( ) ; $ this -> validateInputInstall ( ) ; }
Display simple installation wizard and validates user input
54,439
protected function validateFastInstall ( ) { $ mapping = $ this -> getMappingInstall ( ) ; $ default = $ this -> getDefaultInstall ( ) ; $ this -> setSubmittedMapped ( $ mapping , null , $ default ) ; $ this -> validateComponent ( 'install' ) ; $ this -> errors ( true ) ; }
Validates fast installation
54,440
protected function getDefaultInstall ( ) { $ data = array ( ) ; $ data [ 'database' ] [ 'port' ] = 3306 ; $ data [ 'database' ] [ 'user' ] = 'root' ; $ data [ 'database' ] [ 'type' ] = 'mysql' ; $ data [ 'database' ] [ 'host' ] = 'localhost' ; $ data [ 'database' ] [ 'password' ] = '' ; $ data [ 'store' ] [ 'basepath' ] = '' ; $ data [ 'store' ] [ 'title' ] = 'GPL Cart' ; $ data [ 'store' ] [ 'host' ] = 'localhost' ; $ data [ 'store' ] [ 'timezone' ] = date_default_timezone_get ( ) ; return $ data ; }
Returns an array of default submitted values
54,441
protected function validateInputInstall ( ) { $ this -> setSubmitted ( 'store.language' , $ this -> langcode ) ; $ this -> setSubmitted ( 'store.timezone' , date_default_timezone_get ( ) ) ; $ this -> validateComponent ( 'install' ) ; if ( $ this -> isError ( 'database' ) ) { $ this -> errors ( ) ; $ this -> validateInputDbInstall ( ) ; } $ this -> errors ( true ) ; }
Validates all collected input
54,442
protected function validateInputDbInstall ( ) { $ this -> validatePrompt ( 'database.name' , $ this -> text ( 'Database name' ) , 'install' ) ; $ this -> validatePrompt ( 'database.user' , $ this -> text ( 'Database user' ) , 'install' , 'root' ) ; $ this -> validatePrompt ( 'database.password' , $ this -> text ( 'Database password' ) , 'install' , '' ) ; $ this -> validatePrompt ( 'database.port' , $ this -> text ( 'Database port' ) , 'install' , '3306' ) ; $ this -> validatePrompt ( 'database.host' , $ this -> text ( 'Database port' ) , 'install' , 'localhost' ) ; $ this -> validateInputDbTypeInstall ( ) ; }
Validate database details input
54,443
protected function validateInputDbTypeInstall ( ) { $ drivers = PDO :: getAvailableDrivers ( ) ; $ title = $ this -> text ( 'Database type (enter a number)' ) ; $ input = $ this -> menu ( array_combine ( $ drivers , $ drivers ) , 'mysql' , $ title ) ; if ( ! $ this -> isValidInput ( $ input , 'database.type' , 'install' ) ) { $ this -> errors ( ) ; $ this -> validateInputDbTypeInstall ( ) ; } }
Validates a database port input
54,444
protected function validateInstallerInstall ( ) { $ handlers = $ this -> install -> getHandlers ( ) ; if ( count ( $ handlers ) >= 2 ) { $ options = array ( ) ; foreach ( $ handlers as $ id => $ handler ) { $ options [ $ id ] = $ handler [ 'title' ] ; } $ input = $ this -> menu ( $ options , 'default' , $ this -> text ( 'Installation profile (enter a number)' ) ) ; if ( ! $ this -> isValidInput ( $ input , 'installer' , 'install' ) ) { $ this -> errors ( ) ; $ this -> validateInstallerInstall ( ) ; } } }
Validates installation profile input
54,445
public function getCartQuantity ( array $ options = array ( ) ) { $ options += array ( 'user_id' => $ this -> cart_uid , 'store_id' => $ this -> store_id ) ; return $ this -> cart -> getQuantity ( $ options ) ; }
Returns the number of cart items for the current user
54,446
protected function setFrontendData ( ) { $ currencies = $ this -> currency -> getList ( array ( 'enabled' => true ) ) ; $ this -> data [ '_currencies' ] = $ currencies ; $ this -> data [ '_cart' ] = $ this -> getCartQuantity ( ) ; $ this -> data [ '_wishlist' ] = $ this -> getWishlist ( ) ; $ this -> data [ '_captcha' ] = $ this -> getWidgetCaptcha ( ) ; $ this -> data [ '_comparison' ] = $ this -> getProductComparison ( ) ; $ this -> data [ '_currency' ] = $ currencies [ $ this -> current_currency ] ; $ this -> data [ '_menu' ] = $ this -> getWidgetMenu ( array ( 'items' => $ this -> data_categories ) ) ; }
Sets default data for templates
54,447
protected function setFrontendInstancies ( ) { $ this -> price = $ this -> getInstance ( 'gplcart\\core\\models\\Price' ) ; $ this -> trigger = $ this -> getInstance ( 'gplcart\\core\\models\\Trigger' ) ; $ this -> product = $ this -> getInstance ( 'gplcart\\core\\models\\Product' ) ; $ this -> wishlist = $ this -> getInstance ( 'gplcart\\core\\models\\Wishlist' ) ; $ this -> category = $ this -> getInstance ( 'gplcart\\core\\models\\Category' ) ; $ this -> currency = $ this -> getInstance ( 'gplcart\\core\\models\\Currency' ) ; $ this -> cart_action = $ this -> getInstance ( 'gplcart\\core\\models\\CartAction' ) ; $ this -> product_compare = $ this -> getInstance ( 'gplcart\\core\\models\\ProductCompare' ) ; $ this -> wishlist_action = $ this -> getInstance ( 'gplcart\\core\\models\\WishlistAction' ) ; $ this -> product_compare_action = $ this -> getInstance ( 'gplcart\\core\\models\\ProductCompareAction' ) ; }
Sets model instances
54,448
protected function setFrontendProperties ( ) { if ( ! $ this -> isInstall ( ) ) { if ( ! $ this -> isInternalRoute ( ) ) { $ this -> triggered = $ this -> getTriggered ( ) ; $ this -> data_categories = $ this -> getCategories ( ) ; } $ this -> current_currency = $ this -> currency -> getCode ( ) ; } }
Sets controller s properties
54,449
public function getCart ( array $ conditions = array ( ) ) { $ conditions += array ( 'user_id' => $ this -> cart_uid , 'store_id' => $ this -> store_id ) ; $ cart = $ this -> cart -> getContent ( $ conditions ) ; $ this -> prepareCart ( $ cart ) ; return $ cart ; }
Returns the current cart data
54,450
protected function prepareCart ( array & $ cart ) { if ( ! empty ( $ cart [ 'items' ] ) ) { foreach ( $ cart [ 'items' ] as & $ item ) { $ item [ 'currency' ] = $ cart [ 'currency' ] ; $ this -> prepareCartItem ( $ item ) ; } $ this -> setItemTotalFormatted ( $ cart , $ this -> price ) ; } }
Prepares an array of cart items
54,451
public function getCategories ( $ conditions = array ( ) , $ options = array ( ) ) { $ conditions += array ( 'status' => 1 , 'type' => 'catalog' , 'store_id' => $ this -> store_id ) ; $ options += array ( 'entity' => 'category' , 'imagestyle' => $ this -> configTheme ( 'image_style_category_child' , 3 ) ) ; $ categories = $ this -> category -> getTree ( $ conditions ) ; $ this -> prepareEntityItems ( $ categories , $ options ) ; return $ categories ; }
Returns an array of prepared categories
54,452
public function getProducts ( $ conditions = array ( ) , $ options = array ( ) ) { $ conditions += array ( 'status' => 1 , 'store_id' => $ this -> store_id ) ; if ( isset ( $ conditions [ 'product_id' ] ) && empty ( $ conditions [ 'product_id' ] ) ) { return array ( ) ; } $ options += array ( 'entity' => 'product' ) ; $ products = ( array ) $ this -> product -> getList ( $ conditions ) ; $ this -> prepareEntityItems ( $ products , $ options ) ; return $ products ; }
Loads products from an array of product IDs
54,453
protected function prepareEntityItems ( array & $ items , $ options = array ( ) ) { if ( ! empty ( $ items ) && isset ( $ options [ 'entity' ] ) ) { if ( ! isset ( $ options [ 'view' ] ) || ! in_array ( $ options [ 'view' ] , array ( 'list' , 'grid' ) ) ) { $ options [ 'view' ] = 'grid' ; } $ options += array ( 'entity' => $ options [ 'entity' ] , 'entity_id' => array_keys ( $ items ) , 'template_item' => "{$options['entity']}/item/{$options['view']}" , 'imagestyle' => $ this -> configTheme ( "image_style_{$options['entity']}_{$options['view']}" , 3 ) ) ; foreach ( $ items as & $ item ) { $ this -> prepareEntityItem ( $ item , $ options ) ; } } }
Prepare an array of entity items like pages products etc
54,454
protected function prepareEntityItem ( array & $ item , array $ options ) { $ this -> setItemEntityUrl ( $ item , $ options ) ; $ this -> setItemThumb ( $ item , $ this -> image , $ options ) ; if ( $ options [ 'entity' ] === 'product' ) { $ this -> prepareProductItem ( $ item , $ options ) ; } else { $ this -> setItemIndentation ( $ item ) ; $ this -> setItemUrlActive ( $ item ) ; $ this -> setItemRendered ( $ item , array ( 'item' => $ item ) , $ options ) ; } }
Prepare an entity item
54,455
protected function prepareProductItem ( array & $ product , array $ options ) { $ this -> setItemProductInComparison ( $ product , $ this -> product_compare ) ; $ this -> setItemPriceCalculated ( $ product , $ this -> product ) ; $ this -> setItemProductInWishlist ( $ product , $ this -> wishlist ) ; $ this -> setItemPriceFormatted ( $ product , $ this -> price , $ this -> current_currency ) ; $ this -> setItemProductBundle ( $ product , $ this -> product , $ this -> image ) ; $ this -> setItemRenderedProduct ( $ product , $ options ) ; }
Prepare a product item
54,456
protected function prepareCartItem ( array & $ item ) { $ this -> setItemImages ( $ item [ 'product' ] , 'product' , $ this -> image ) ; $ this -> setItemThumbCart ( $ item , $ this -> image ) ; $ this -> setItemPriceFormatted ( $ item , $ this -> price , $ this -> current_currency ) ; $ this -> setItemTotalFormatted ( $ item , $ this -> price ) ; $ this -> setItemProductBundle ( $ item [ 'product' ] , $ this -> product , $ this -> image ) ; }
Prepare a cart item Prepare cart item
54,457
public function add ( array $ data ) { $ result = null ; $ this -> hook -> attach ( 'category.group.add.before' , $ data , $ result , $ this ) ; if ( isset ( $ result ) ) { return ( int ) $ result ; } $ result = $ data [ 'category_group_id' ] = $ this -> db -> insert ( 'category_group' , $ data ) ; $ this -> setTranslations ( $ data , $ this -> translation_entity , 'category_group' , false ) ; $ this -> hook -> attach ( 'category.group.add.after' , $ data , $ result , $ this ) ; return ( int ) $ result ; }
Adds a category group
54,458
public function canDelete ( $ category_group_id ) { $ sql = 'SELECT category_id FROM category WHERE category_group_id=?' ; $ result = $ this -> db -> fetchColumn ( $ sql , array ( $ category_group_id ) ) ; return empty ( $ result ) ; }
Whether a category group can be deleted
54,459
public function getTypes ( ) { $ types = array ( 'brand' => $ this -> translation -> text ( 'Brand' ) , 'common' => $ this -> translation -> text ( 'Common' ) , 'catalog' => $ this -> translation -> text ( 'Catalog' ) ) ; $ this -> hook -> attach ( 'category.group.types' , $ types , $ this ) ; return $ types ; }
Returns an array of category group types
54,460
public function addLog ( string $ string , array $ logData = [ ] ) : bool { if ( null !== $ this -> logger ) { $ this -> logger -> debug ( 'CORs: ' . $ string , $ logData ) ; return true ; } return false ; }
Add a log string if we have a logger .
54,461
public function setSettings ( array $ settings = [ ] ) : self { $ this -> settings = array_merge ( $ this -> settings , $ settings ) ; foreach ( $ this -> allowedSettings as $ name => $ allowed ) { $ this -> validateSettings -> __invoke ( $ name , $ this -> settings [ $ name ] , $ allowed ) ; } return $ this ; }
Set the settings .
54,462
public function generate ( $ pattern , array $ options = array ( ) ) { $ options += array ( 'translit' => true , 'language' => null , 'placeholders' => array ( ) ) ; $ result = null ; $ this -> hook -> attach ( 'alias.generate.before' , $ pattern , $ options , $ result ) ; if ( isset ( $ result ) ) { return ( string ) $ result ; } $ alias = $ pattern ; if ( ! empty ( $ options [ 'placeholders' ] ) ) { $ alias = gplcart_string_replace ( $ pattern , $ options [ 'placeholders' ] , $ options ) ; } if ( ! empty ( $ options [ 'translit' ] ) ) { $ alias = gplcart_string_slug ( $ this -> language -> translit ( $ alias , $ options [ 'language' ] ) ) ; } $ trimmed = mb_strimwidth ( str_replace ( ' ' , '-' , trim ( $ alias ) ) , 0 , 100 , '' ) ; $ result = $ this -> getUnique ( $ trimmed ) ; $ this -> hook -> attach ( 'alias.generate.after' , $ pattern , $ options , $ result ) ; return $ result ; }
Generate a URL alias using a pattern and an array of data
54,463
public function generateEntity ( $ entity , array $ data ) { $ handlers = $ this -> getHandlers ( ) ; if ( isset ( $ handlers [ $ entity ] [ 'mapping' ] ) && isset ( $ handlers [ $ entity ] [ 'pattern' ] ) ) { $ data += array ( 'placeholders' => $ handlers [ $ entity ] [ 'mapping' ] ) ; return $ this -> generate ( $ handlers [ $ entity ] [ 'pattern' ] , $ data ) ; } return null ; }
Generates an alias for an entity
54,464
public function loadEntity ( $ entity , $ entity_id ) { try { $ handlers = $ this -> getHandlers ( ) ; return Handler :: call ( $ handlers , $ entity , 'data' , array ( $ entity_id ) ) ; } catch ( Exception $ ex ) { return array ( ) ; } }
Returns an array of entity data
54,465
public function getUnique ( $ alias ) { if ( ! $ this -> exists ( $ alias ) ) { return $ alias ; } $ info = pathinfo ( $ alias ) ; $ ext = isset ( $ info [ 'extension' ] ) ? '.' . $ info [ 'extension' ] : '' ; $ counter = 0 ; do { $ counter ++ ; $ modified = $ info [ 'filename' ] . '-' . $ counter . $ ext ; } while ( $ this -> exists ( $ modified ) ) ; return $ modified ; }
Returns a unique alias using a base string
54,466
public function exists ( $ path ) { foreach ( $ this -> route -> getList ( ) as $ route ) { if ( isset ( $ route [ 'pattern' ] ) && $ route [ 'pattern' ] === $ path ) { return true ; } } return ( bool ) $ this -> get ( array ( 'alias' => $ path ) ) ; }
Whether the alias path already exists
54,467
public function setSubmitted ( $ key , $ value ) { gplcart_array_set ( $ this -> submitted , $ this -> getKeyPath ( $ key ) , $ value ) ; }
Sets a value to an array of submitted values
54,468
protected function getKeyPath ( $ key ) { if ( empty ( $ this -> options [ 'parents' ] ) ) { return $ key ; } if ( is_string ( $ this -> options [ 'parents' ] ) ) { $ this -> options [ 'parents' ] = explode ( '.' , $ this -> options [ 'parents' ] ) ; } if ( is_string ( $ key ) ) { $ key = explode ( '.' , $ key ) ; } return array_merge ( ( array ) $ this -> options [ 'parents' ] , ( array ) $ key ) ; }
Returns an array that represents a path to a nested array value
54,469
protected function isExcluded ( $ field ) { return isset ( $ this -> options [ 'field' ] ) && $ this -> options [ 'field' ] !== $ this -> getKey ( $ field ) ; }
Whether the field should be excluded from validation
54,470
protected function setError ( $ key , $ error ) { gplcart_array_set ( $ this -> errors , $ this -> getKeyPath ( $ key ) , $ error ) ; return $ this -> errors ; }
Sets a validation error
54,471
protected function isError ( $ key = null ) { if ( ! isset ( $ key ) ) { return ! empty ( $ this -> errors ) ; } $ result = $ this -> getError ( $ key ) ; return ! empty ( $ result ) ; }
Whether an error exists
54,472
protected function getResult ( ) { $ result = empty ( $ this -> errors ) ? true : $ this -> errors ; $ this -> errors = array ( ) ; return $ result ; }
Returns validation results
54,473
public function product ( array $ condition , array $ data ) { $ is_product = ( int ) isset ( $ data [ 'product_id' ] ) ; $ value = ( int ) filter_var ( reset ( $ condition [ 'value' ] ) , FILTER_VALIDATE_BOOLEAN ) ; return $ this -> compare ( $ is_product , $ value , $ condition [ 'operator' ] ) ; }
Whether the product scope condition is met
54,474
public function cart ( array $ condition , array $ data ) { $ is_cart = ( int ) isset ( $ data [ 'cart_id' ] ) ; $ value = ( int ) filter_var ( reset ( $ condition [ 'value' ] ) , FILTER_VALIDATE_BOOLEAN ) ; return $ this -> compare ( $ is_cart , $ value , $ condition [ 'operator' ] ) ; }
Whether the cart scope condition is met
54,475
public function order ( array $ condition , array $ data ) { $ is_order = ( int ) isset ( $ data [ 'order_id' ] ) ; $ value = ( int ) filter_var ( reset ( $ condition [ 'value' ] ) , FILTER_VALIDATE_BOOLEAN ) ; return $ this -> compare ( $ is_order , $ value , $ condition [ 'operator' ] ) ; }
Whether the order scope condition is met
54,476
public function editInstall ( ) { $ this -> controlAccessInstall ( ) ; $ this -> translation -> set ( $ this -> install_language , null ) ; $ this -> setTitleEditInstall ( ) ; $ requirements = $ this -> getRequirementsInstall ( ) ; $ issues = $ this -> getRequirementErrorsInstall ( $ requirements ) ; $ this -> setData ( 'issues' , $ issues ) ; $ this -> setData ( 'requirements' , $ requirements ) ; $ this -> setData ( 'settings.installer' , 'default' ) ; $ this -> setData ( 'timezones' , gplcart_timezones ( ) ) ; $ this -> setData ( 'language' , $ this -> install_language ) ; $ this -> setData ( 'handlers' , $ this -> install -> getHandlers ( ) ) ; $ this -> setData ( 'languages' , $ this -> getLanguagesInstall ( ) ) ; $ this -> setData ( 'severity' , $ this -> getSeverityInstall ( $ issues ) ) ; $ this -> setData ( 'settings.store.language' , $ this -> install_language ) ; $ this -> submitEditInstall ( ) ; $ this -> outputEditInstall ( ) ; }
Displays the installation page
54,477
protected function getLanguagesInstall ( ) { $ languages = array ( ) ; foreach ( $ this -> language -> getList ( ) as $ code => $ language ) { if ( $ code === 'en' || is_file ( $ this -> translation -> getFile ( $ code ) ) ) { $ languages [ $ code ] = $ language ; } } return $ languages ; }
Returns an array of existing languages
54,478
protected function processInstall ( ) { $ result = $ this -> install -> process ( $ this -> getSubmitted ( ) ) ; $ this -> redirect ( $ result [ 'redirect' ] , $ result [ 'message' ] , $ result [ 'severity' ] ) ; }
Performs all needed operations to install the system
54,479
protected function validateEditInstall ( ) { $ this -> setSubmitted ( 'settings' ) ; $ this -> setSubmitted ( 'store.host' , $ this -> server -> httpHost ( ) ) ; $ this -> setSubmitted ( 'store.language' , $ this -> install_language ) ; $ this -> setSubmitted ( 'store.basepath' , trim ( $ this -> request -> base ( true ) , '/' ) ) ; $ this -> validateComponent ( 'install' ) ; return ! $ this -> hasErrors ( false ) ; }
Validates an array of submitted form values
54,480
public function indexAccount ( $ user_id ) { $ this -> setUserAccount ( $ user_id ) ; $ this -> setTitleIndexAccount ( ) ; $ this -> setBreadcrumbIndexAccount ( ) ; $ this -> setFilter ( ) ; $ this -> setPagerOrderIndexAccount ( ) ; $ this -> setData ( 'user' , $ this -> data_user ) ; $ this -> setData ( 'orders' , $ this -> getListOrderAccount ( ) ) ; $ this -> outputIndexAccount ( ) ; }
Page callback Displays the user account page
54,481
protected function getListOrderAccount ( ) { $ conditions = $ this -> query_filter ; $ conditions [ 'order' ] = 'desc' ; $ conditions [ 'sort' ] = 'created' ; $ conditions [ 'limit' ] = $ this -> data_limit ; $ conditions [ 'user_id' ] = $ this -> data_user [ 'user_id' ] ; $ list = ( array ) $ this -> order -> getList ( $ conditions ) ; $ this -> prepareListOrderAccount ( $ list ) ; return $ list ; }
Returns an array of orders for the user
54,482
public function editAccount ( $ user_id ) { $ this -> setUserAccount ( $ user_id ) ; $ this -> controlAccessEditAccount ( ) ; $ this -> setTitleEditAccount ( ) ; $ this -> setBreadcrumbEditAccount ( ) ; $ this -> setData ( 'user' , $ this -> data_user ) ; $ this -> submitEditAccount ( ) ; $ this -> outputEditAccount ( ) ; }
Page callback Displays the edit account page
54,483
protected function setBreadcrumbEditAccount ( ) { $ breadcrumbs = array ( ) ; $ breadcrumbs [ ] = array ( 'url' => $ this -> url ( '/' ) , 'text' => $ this -> text ( 'Shop' ) ) ; $ breadcrumbs [ ] = array ( 'text' => $ this -> text ( 'Account' ) , 'url' => $ this -> url ( "account/{$this->data_user['user_id']}" ) ) ; $ this -> setBreadcrumbs ( $ breadcrumbs ) ; }
Sets breadcrumbs on the edit account page
54,484
public function editUserForgot ( ) { $ this -> controlAccessUserForgot ( ) ; $ this -> setUserForgot ( ) ; $ this -> setTitleEditUserForgot ( ) ; $ this -> setBreadcrumbEditUserForgot ( ) ; $ this -> setData ( 'forgetful_user' , $ this -> data_user ) ; $ this -> setData ( 'password_limit' , $ this -> user -> getPasswordLength ( ) ) ; $ this -> submitUserForgot ( ) ; $ this -> outputEditUserForgot ( ) ; }
Displays the password reset page
54,485
protected function setUserForgot ( ) { $ token = $ this -> getQuery ( 'key' ) ; $ user_id = $ this -> getQuery ( 'user_id' ) ; $ this -> data_user = array ( ) ; if ( ! empty ( $ token ) && is_numeric ( $ user_id ) ) { $ this -> data_user = $ this -> user -> get ( $ user_id ) ; $ this -> controlTokenUserForgot ( $ this -> data_user , $ token ) ; } }
Returns a user from the current reset password URL
54,486
protected function controlTokenUserForgot ( $ user , $ token ) { if ( ! empty ( $ user [ 'status' ] ) ) { if ( empty ( $ user [ 'data' ] [ 'reset_password' ] [ 'token' ] ) ) { $ this -> redirect ( 'forgot' ) ; } if ( ! gplcart_string_equals ( $ user [ 'data' ] [ 'reset_password' ] [ 'token' ] , $ token ) ) { $ this -> outputHttpStatus ( 403 ) ; } if ( empty ( $ user [ 'data' ] [ 'reset_password' ] [ 'expires' ] ) || $ user [ 'data' ] [ 'reset_password' ] [ 'expires' ] < GC_TIME ) { $ this -> redirect ( 'forgot' ) ; } } }
Validates the token and its expiration time set for the user
54,487
protected function resetPasswordUser ( ) { $ result = $ this -> user_action -> resetPassword ( $ this -> getSubmitted ( ) ) ; $ this -> redirect ( $ result [ 'redirect' ] , $ result [ 'message' ] , $ result [ 'severity' ] ) ; }
Reset user s password
54,488
protected function validateUserForgot ( ) { $ this -> setSubmitted ( 'user' , null , false ) ; $ this -> filterSubmitted ( array ( 'email' , 'password' ) ) ; $ this -> setSubmitted ( 'user' , $ this -> data_user ) ; $ this -> validateComponent ( 'user_reset_password' ) ; return ! $ this -> hasErrors ( ) ; }
Validates a submitted data when a user wants to reset its password
54,489
public function countryState ( array $ submitted , array $ options = array ( ) ) { $ this -> options = $ options ; $ this -> submitted = & $ submitted ; $ this -> validateCountryState ( ) ; $ this -> validateBool ( 'status' ) ; $ this -> validateCodeCountryState ( ) ; $ this -> validateName ( ) ; $ this -> validateCountryCountryState ( ) ; $ this -> validateZoneCountryState ( ) ; $ this -> unsetSubmitted ( 'update' ) ; return $ this -> getResult ( ) ; }
Performs full country state validation
54,490
protected function validateCountryState ( ) { $ id = $ this -> getUpdatingId ( ) ; if ( $ id === false ) { return null ; } $ data = $ this -> state -> get ( $ id ) ; if ( empty ( $ data ) ) { $ this -> setErrorUnavailable ( 'update' , $ this -> translation -> text ( 'Country state' ) ) ; return false ; } $ this -> setUpdating ( $ data ) ; return true ; }
Validates a state to be updated
54,491
public function validateCodeCountryState ( ) { $ field = 'code' ; if ( $ this -> isExcluded ( $ field ) ) { return null ; } $ value = $ this -> getSubmitted ( $ field ) ; if ( $ this -> isUpdating ( ) && ! isset ( $ value ) ) { $ this -> unsetSubmitted ( $ field ) ; return null ; } $ updating = $ this -> getUpdating ( ) ; if ( isset ( $ updating [ 'code' ] ) && $ updating [ 'code' ] === $ value ) { return true ; } $ label = $ this -> translation -> text ( 'Code' ) ; if ( empty ( $ value ) ) { $ this -> setErrorRequired ( $ field , $ label ) ; return false ; } $ existing = $ this -> state -> getList ( array ( 'code' => $ value , 'country' => $ this -> getSubmitted ( 'country' ) ) ) ; if ( ! empty ( $ existing ) ) { $ this -> setErrorExists ( $ field , $ label ) ; return false ; } return true ; }
Validates a state code
54,492
protected function validateZoneCountryState ( ) { $ field = 'zone_id' ; $ value = $ this -> getSubmitted ( $ field ) ; if ( empty ( $ value ) ) { return null ; } $ label = $ this -> translation -> text ( 'Zone' ) ; if ( ! is_numeric ( $ value ) ) { $ this -> setErrorNumeric ( $ field , $ label ) ; return false ; } $ zone = $ this -> zone -> get ( $ value ) ; if ( empty ( $ zone ) ) { $ this -> setErrorUnavailable ( $ field , $ label ) ; return false ; } return true ; }
Validates a zone ID
54,493
public function dateformat ( array $ submitted , array $ options ) { $ options += array ( 'field' => null , 'label' => null ) ; $ value = gplcart_array_get ( $ submitted , $ options [ 'field' ] ) ; if ( strtotime ( $ value ) === false ) { return $ this -> setErrorInvalid ( $ options [ 'field' ] , $ options [ 'label' ] ) ; } return true ; }
Validates the date format
54,494
public function id ( array $ condition , array $ data ) { if ( empty ( $ data [ 'product_id' ] ) ) { return false ; } return $ this -> compare ( $ data [ 'product_id' ] , $ condition [ 'value' ] , $ condition [ 'operator' ] ) ; }
Whether the product ID condition is met
54,495
public function categoryId ( array $ condition , array $ data ) { if ( empty ( $ data [ 'product_id' ] ) || empty ( $ data [ 'category_id' ] ) ) { return false ; } return $ this -> compare ( $ data [ 'category_id' ] , $ condition [ 'value' ] , $ condition [ 'operator' ] ) ; }
Whether the product category ID condition is met
54,496
public function brandCategoryId ( array $ condition , array $ data ) { if ( empty ( empty ( $ data [ 'product_id' ] ) || $ data [ 'brand_category_id' ] ) ) { return false ; } return $ this -> compare ( $ data [ 'brand_category_id' ] , $ condition [ 'value' ] , $ condition [ 'operator' ] ) ; }
Whether the product brand condition is met
54,497
protected function retrieveConfigPostMetas ( $ post , $ postTypeModel ) { $ metaKeys = [ ] ; $ metaTaxonomies = [ ] ; $ allKeys = $ this -> getValidationsKeys ( $ postTypeModel ) ; foreach ( $ allKeys as $ key => $ value ) { $ customFieldObject = $ this -> getCustomFieldObject ( $ postTypeModel , $ key ) ; if ( isset ( $ customFieldObject [ 'type' ] ) && $ customFieldObject [ 'type' ] == 'taxonomy' ) { if ( array_key_exists ( 'post_type' , $ customFieldObject ) ) { $ customfieldPostTypes = $ this -> getPostTypeIdentifiers ( $ customFieldObject [ 'post_type' ] ) ; $ taxonomyIds = $ post -> taxonomies ( ) -> whereIn ( 'post_type' , $ customfieldPostTypes ) -> get ( ) ; $ ids = [ ] ; foreach ( $ taxonomyIds as $ value ) { array_push ( $ ids , $ value -> id ) ; } $ ids = json_encode ( $ ids ) ; $ metaTaxonomies [ $ key ] = [ 'meta_key' => $ key , 'meta_value' => $ ids , ] ; } } else { array_push ( $ metaKeys , $ key ) ; } } $ postmetaSimple = $ post -> postmeta ( ) -> whereIn ( 'meta_key' , $ metaKeys ) -> select ( [ 'meta_key' , 'meta_value' ] ) -> get ( ) -> keyBy ( 'meta_key' ) -> toArray ( ) ; $ defaultPostData = [ ] ; $ defaultPostData [ 'post_title' ] = [ 'meta_key' => 'post_title' , 'meta_value' => $ post -> post_title , ] ; $ defaultPostData [ 'post_name' ] = [ 'meta_key' => 'post_name' , 'meta_value' => $ post -> post_name , ] ; $ postmeta = array_merge ( $ postmetaSimple , $ metaTaxonomies , $ defaultPostData ) ; return $ postmeta ; }
Get all the post meta keys of the post
54,498
public function productClassField ( array & $ submitted , array $ options = array ( ) ) { $ this -> options = $ options ; $ this -> submitted = & $ submitted ; $ this -> validateProductClassField ( ) ; $ this -> validateProductClassProductClassField ( ) ; $ this -> validateWeight ( ) ; $ this -> validateBool ( 'required' ) ; $ this -> validateBool ( 'multiple' ) ; $ this -> validateFieldIdProductClassField ( ) ; $ this -> unsetSubmitted ( 'update' ) ; return $ this -> getResult ( ) ; }
Performs full product class field validation
54,499
protected function validateProductClassField ( ) { $ id = $ this -> getUpdatingId ( ) ; if ( $ id === false ) { return null ; } $ data = $ this -> product_class_field -> get ( $ id ) ; if ( empty ( $ data ) ) { $ this -> setErrorUnavailable ( 'update' , $ this -> translation -> text ( 'Address' ) ) ; return false ; } $ this -> setUpdating ( $ data ) ; return true ; }
Validates a product class field to be updated