repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
ezsystems/ezfind
bin/php/updatesearchindexsolr.php
ezfUpdateSearchIndexSolr.execute
protected function execute( $nodeID, $offset, $limit ) { $count = 0; $node = eZContentObjectTreeNode::fetch( $nodeID ); if ( !( $node instanceof eZContentObjectTreeNode ) ) { $this->CLI->error( "An error occured while trying fetching node $nodeID" ); return 0; } $searchEngine = new eZSolr(); if ( $subTree = $node->subTree( array( 'Offset' => $offset, 'Limit' => $limit, 'SortBy' => array(), 'Limitation' => array(), 'MainNodeOnly' => true ) ) ) { foreach ( $subTree as $innerNode ) { $object = $innerNode->attribute( 'object' ); if ( !$object ) { continue; } //pass false as we are going to do a commit at the end $result = $searchEngine->addObject( $object, false, $this->commitWithin * 1000 ); if ( !$result ) { $this->CLI->error( ' Failed indexing ' . $object->attribute('class_identifier') . ' object with ID ' . $object->attribute( 'id' ) ); } ++$count; } } return $count; }
php
protected function execute( $nodeID, $offset, $limit ) { $count = 0; $node = eZContentObjectTreeNode::fetch( $nodeID ); if ( !( $node instanceof eZContentObjectTreeNode ) ) { $this->CLI->error( "An error occured while trying fetching node $nodeID" ); return 0; } $searchEngine = new eZSolr(); if ( $subTree = $node->subTree( array( 'Offset' => $offset, 'Limit' => $limit, 'SortBy' => array(), 'Limitation' => array(), 'MainNodeOnly' => true ) ) ) { foreach ( $subTree as $innerNode ) { $object = $innerNode->attribute( 'object' ); if ( !$object ) { continue; } //pass false as we are going to do a commit at the end $result = $searchEngine->addObject( $object, false, $this->commitWithin * 1000 ); if ( !$result ) { $this->CLI->error( ' Failed indexing ' . $object->attribute('class_identifier') . ' object with ID ' . $object->attribute( 'id' ) ); } ++$count; } } return $count; }
[ "protected", "function", "execute", "(", "$", "nodeID", ",", "$", "offset", ",", "$", "limit", ")", "{", "$", "count", "=", "0", ";", "$", "node", "=", "eZContentObjectTreeNode", "::", "fetch", "(", "$", "nodeID", ")", ";", "if", "(", "!", "(", "$"...
Execute indexing of subtree @param int $nodeID @param int $offset @param int $limit @return int Number of objects indexed.
[ "Execute", "indexing", "of", "subtree" ]
b11eac0cee490826d5a55ec9e5642cb156b1a8ec
https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/bin/php/updatesearchindexsolr.php#L403-L445
train
ezsystems/ezfind
bin/php/updatesearchindexsolr.php
ezfUpdateSearchIndexSolr.objectCount
protected function objectCount() { $topNodeArray = eZPersistentObject::fetchObjectList( eZContentObjectTreeNode::definition(), null, array( 'parent_node_id' => 1, 'depth' => 1 ) ); $subTreeCount = 0; foreach ( array_keys ( $topNodeArray ) as $key ) { $subTreeCount += $topNodeArray[$key]->subTreeCount( array( 'Limitation' => array(), 'MainNodeOnly' => true ) ); } return $subTreeCount; }
php
protected function objectCount() { $topNodeArray = eZPersistentObject::fetchObjectList( eZContentObjectTreeNode::definition(), null, array( 'parent_node_id' => 1, 'depth' => 1 ) ); $subTreeCount = 0; foreach ( array_keys ( $topNodeArray ) as $key ) { $subTreeCount += $topNodeArray[$key]->subTreeCount( array( 'Limitation' => array(), 'MainNodeOnly' => true ) ); } return $subTreeCount; }
[ "protected", "function", "objectCount", "(", ")", "{", "$", "topNodeArray", "=", "eZPersistentObject", "::", "fetchObjectList", "(", "eZContentObjectTreeNode", "::", "definition", "(", ")", ",", "null", ",", "array", "(", "'parent_node_id'", "=>", "1", ",", "'de...
Get total number of objects @return int Total object count
[ "Get", "total", "number", "of", "objects" ]
b11eac0cee490826d5a55ec9e5642cb156b1a8ec
https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/bin/php/updatesearchindexsolr.php#L452-L466
train
ezsystems/ezfind
bin/php/updatesearchindexsolr.php
ezfUpdateSearchIndexSolr.initializeDB
protected function initializeDB() { $dbUser = $this->Options['db-user'] ? $this->Options['db-user'] : false; $dbPassword = $this->Options['db-password'] ? $this->Options['db-password'] : false; $dbHost = $this->Options['db-host'] ? $this->Options['db-host'] : false; $dbName = $this->Options['db-database'] ? $this->Options['db-database'] : false; $dbImpl = $this->Options['db-driver'] ? $this->Options['db-driver'] : false; $showSQL = $this->Options['sql'] ? true : false; // Forcing creation of new instance to avoid mysql wait_timeout to kill // the connection before it's done $db = eZDB::instance( false, false, true ); if ( $dbHost or $dbName or $dbUser or $dbImpl ) { $params = array(); if ( $dbHost !== false ) $params['server'] = $dbHost; if ( $dbUser !== false ) { $params['user'] = $dbUser; $params['password'] = ''; } if ( $dbPassword !== false ) $params['password'] = $dbPassword; if ( $dbName !== false ) $params['database'] = $dbName; $db = eZDB::instance( $dbImpl, $params, true ); eZDB::setInstance( $db ); } $db->setIsSQLOutputEnabled( $showSQL ); }
php
protected function initializeDB() { $dbUser = $this->Options['db-user'] ? $this->Options['db-user'] : false; $dbPassword = $this->Options['db-password'] ? $this->Options['db-password'] : false; $dbHost = $this->Options['db-host'] ? $this->Options['db-host'] : false; $dbName = $this->Options['db-database'] ? $this->Options['db-database'] : false; $dbImpl = $this->Options['db-driver'] ? $this->Options['db-driver'] : false; $showSQL = $this->Options['sql'] ? true : false; // Forcing creation of new instance to avoid mysql wait_timeout to kill // the connection before it's done $db = eZDB::instance( false, false, true ); if ( $dbHost or $dbName or $dbUser or $dbImpl ) { $params = array(); if ( $dbHost !== false ) $params['server'] = $dbHost; if ( $dbUser !== false ) { $params['user'] = $dbUser; $params['password'] = ''; } if ( $dbPassword !== false ) $params['password'] = $dbPassword; if ( $dbName !== false ) $params['database'] = $dbName; $db = eZDB::instance( $dbImpl, $params, true ); eZDB::setInstance( $db ); } $db->setIsSQLOutputEnabled( $showSQL ); }
[ "protected", "function", "initializeDB", "(", ")", "{", "$", "dbUser", "=", "$", "this", "->", "Options", "[", "'db-user'", "]", "?", "$", "this", "->", "Options", "[", "'db-user'", "]", ":", "false", ";", "$", "dbPassword", "=", "$", "this", "->", "...
Create custom DB connection if DB options provided
[ "Create", "custom", "DB", "connection", "if", "DB", "options", "provided" ]
b11eac0cee490826d5a55ec9e5642cb156b1a8ec
https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/bin/php/updatesearchindexsolr.php#L505-L537
train
ezsystems/ezfind
bin/php/updatesearchindexsolr.php
ezfUpdateSearchIndexSolr.checkSolrRunning
protected function checkSolrRunning() { $eZFindINI = eZINI::instance( 'ezfind.ini' ); if ( $eZFindINI->variable( 'LanguageSearch', 'MultiCore' ) === 'enabled' ) { $shards = eZINI::instance( 'solr.ini' )->variable( 'SolrBase', 'Shards' ); foreach ( $eZFindINI->variable( 'LanguageSearch', 'LanguagesCoresMap' ) as $locale => $coreName ) { if ( isset( $shards[$coreName] ) ) { if ( !$this->isSolrRunning( $shards[$coreName] ) ) { $this->CLI->error( "The '$coreName' Solr core is not running." ); $this->CLI->error( 'Please, ensure the server is started and the configurations of eZ Find and Solr are correct.' ); return false; } } else { $this->CLI->error( "Locale '$locale' is mapped to a core that is not listed in solr.ini/[SolrBase]/Shards." ); return false; } } return true; } else { $ret = $this->isSolrRunning(); if ( !$ret ) { $this->CLI->error( "The Solr server couldn't be reached." ); $this->CLI->error( 'Please, ensure the server is started and the configuration of eZ Find is correct.' ); } return $ret; } }
php
protected function checkSolrRunning() { $eZFindINI = eZINI::instance( 'ezfind.ini' ); if ( $eZFindINI->variable( 'LanguageSearch', 'MultiCore' ) === 'enabled' ) { $shards = eZINI::instance( 'solr.ini' )->variable( 'SolrBase', 'Shards' ); foreach ( $eZFindINI->variable( 'LanguageSearch', 'LanguagesCoresMap' ) as $locale => $coreName ) { if ( isset( $shards[$coreName] ) ) { if ( !$this->isSolrRunning( $shards[$coreName] ) ) { $this->CLI->error( "The '$coreName' Solr core is not running." ); $this->CLI->error( 'Please, ensure the server is started and the configurations of eZ Find and Solr are correct.' ); return false; } } else { $this->CLI->error( "Locale '$locale' is mapped to a core that is not listed in solr.ini/[SolrBase]/Shards." ); return false; } } return true; } else { $ret = $this->isSolrRunning(); if ( !$ret ) { $this->CLI->error( "The Solr server couldn't be reached." ); $this->CLI->error( 'Please, ensure the server is started and the configuration of eZ Find is correct.' ); } return $ret; } }
[ "protected", "function", "checkSolrRunning", "(", ")", "{", "$", "eZFindINI", "=", "eZINI", "::", "instance", "(", "'ezfind.ini'", ")", ";", "if", "(", "$", "eZFindINI", "->", "variable", "(", "'LanguageSearch'", ",", "'MultiCore'", ")", "===", "'enabled'", ...
Tells whether Solr is running by replying to ping request. In a multicore setup, all cores used to index content are checked. @return bool
[ "Tells", "whether", "Solr", "is", "running", "by", "replying", "to", "ping", "request", ".", "In", "a", "multicore", "setup", "all", "cores", "used", "to", "index", "content", "are", "checked", "." ]
b11eac0cee490826d5a55ec9e5642cb156b1a8ec
https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/bin/php/updatesearchindexsolr.php#L574-L609
train
ezsystems/ezfind
classes/ezfsolrdocumentfieldobjectrelation.php
ezfSolrDocumentFieldObjectRelation.getTypeForSubattribute
protected static function getTypeForSubattribute( eZContentClassAttribute $classAttribute, $subAttribute, $context = 'search' ) { $q = "SELECT DISTINCT( ezcoa.data_type_string ) FROM ezcontentobject_link AS ezcol, ezcontentobject_attribute AS ezcoa, ezcontentclass_attribute AS ezcca, ezcontentclass_attribute AS ezcca_target WHERE ezcol.contentclassattribute_id={$classAttribute->attribute( 'id' )} AND ezcca_target.identifier='{$subAttribute}' AND ezcca.data_type_string='{$classAttribute->attribute( 'data_type_string' )}' AND ezcca.id=ezcol.contentclassattribute_id AND ezcol.to_contentobject_id = ezcoa.contentobject_id AND ezcoa.contentclassattribute_id = ezcca_target.id; "; $rows = eZDB::instance()->arrayQuery( $q ); if ( $rows and count( $rows ) > 0 ) { if ( count( $rows ) > 1 ) { $msg = "Multiple types were found for subattribute '{$subAttribute}' of class attribute #{$classAttribute->attribute( 'id' )} [{$classAttribute->attribute( 'data_type_string' )}]. This means that objects of different content classes were related through class attribute #{$classAttribute->attribute( 'id' )} and had attributes named '{$subAttribute}' of different datatypes : \n" . print_r( $rows , true ) . " Picking the first one here : {$rows[0]['data_type_string']}"; eZDebug::writeWarning( $msg, __METHOD__ ); } return ezfSolrDocumentFieldBase::getClassAttributeType( new eZContentClassAttribute( $rows[0] ), null, $context ); } return false; }
php
protected static function getTypeForSubattribute( eZContentClassAttribute $classAttribute, $subAttribute, $context = 'search' ) { $q = "SELECT DISTINCT( ezcoa.data_type_string ) FROM ezcontentobject_link AS ezcol, ezcontentobject_attribute AS ezcoa, ezcontentclass_attribute AS ezcca, ezcontentclass_attribute AS ezcca_target WHERE ezcol.contentclassattribute_id={$classAttribute->attribute( 'id' )} AND ezcca_target.identifier='{$subAttribute}' AND ezcca.data_type_string='{$classAttribute->attribute( 'data_type_string' )}' AND ezcca.id=ezcol.contentclassattribute_id AND ezcol.to_contentobject_id = ezcoa.contentobject_id AND ezcoa.contentclassattribute_id = ezcca_target.id; "; $rows = eZDB::instance()->arrayQuery( $q ); if ( $rows and count( $rows ) > 0 ) { if ( count( $rows ) > 1 ) { $msg = "Multiple types were found for subattribute '{$subAttribute}' of class attribute #{$classAttribute->attribute( 'id' )} [{$classAttribute->attribute( 'data_type_string' )}]. This means that objects of different content classes were related through class attribute #{$classAttribute->attribute( 'id' )} and had attributes named '{$subAttribute}' of different datatypes : \n" . print_r( $rows , true ) . " Picking the first one here : {$rows[0]['data_type_string']}"; eZDebug::writeWarning( $msg, __METHOD__ ); } return ezfSolrDocumentFieldBase::getClassAttributeType( new eZContentClassAttribute( $rows[0] ), null, $context ); } return false; }
[ "protected", "static", "function", "getTypeForSubattribute", "(", "eZContentClassAttribute", "$", "classAttribute", ",", "$", "subAttribute", ",", "$", "context", "=", "'search'", ")", "{", "$", "q", "=", "\"SELECT DISTINCT( ezcoa.data_type_string )\n FROM ...
Identifies, based on the existing object relations, the type of the subattribute. @param eZContentClassAttribute $classAttribute The ezobjectrelation/ezobjectrelationlist attribute @param $subAttribute The subattribute's name @return string The type of the subattribute, false otherwise.
[ "Identifies", "based", "on", "the", "existing", "object", "relations", "the", "type", "of", "the", "subattribute", "." ]
b11eac0cee490826d5a55ec9e5642cb156b1a8ec
https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/classes/ezfsolrdocumentfieldobjectrelation.php#L127-L157
train
ezsystems/ezfind
classes/ezfsolrdocumentfieldobjectrelation.php
ezfSolrDocumentFieldObjectRelation.getBaseList
function getBaseList( eZContentObjectVersion $objectVersion ) { $returnList = array(); // Get ezfSolrDocumentFieldBase instance for all attributes in related object if ( eZContentObject::recursionProtect( $this->ContentObjectAttribute->attribute( 'contentobject_id' ) ) ) { foreach ( $objectVersion->contentObjectAttributes( $this->ContentObjectAttribute->attribute( 'language_code' ) ) as $attribute ) { if ( $attribute->attribute( 'contentclass_attribute' )->attribute( 'is_searchable' ) ) { $returnList[] = ezfSolrDocumentFieldBase::getInstance( $attribute ); } } } return $returnList; }
php
function getBaseList( eZContentObjectVersion $objectVersion ) { $returnList = array(); // Get ezfSolrDocumentFieldBase instance for all attributes in related object if ( eZContentObject::recursionProtect( $this->ContentObjectAttribute->attribute( 'contentobject_id' ) ) ) { foreach ( $objectVersion->contentObjectAttributes( $this->ContentObjectAttribute->attribute( 'language_code' ) ) as $attribute ) { if ( $attribute->attribute( 'contentclass_attribute' )->attribute( 'is_searchable' ) ) { $returnList[] = ezfSolrDocumentFieldBase::getInstance( $attribute ); } } } return $returnList; }
[ "function", "getBaseList", "(", "eZContentObjectVersion", "$", "objectVersion", ")", "{", "$", "returnList", "=", "array", "(", ")", ";", "// Get ezfSolrDocumentFieldBase instance for all attributes in related object", "if", "(", "eZContentObject", "::", "recursionProtect", ...
Get ezfSolrDocumentFieldBase instances for all attributes of specified eZContentObjectVersion @param eZContentObjectVersion Instance of eZContentObjectVersion to fetch attributes from. @return array List of ezfSolrDocumentFieldBase instances.
[ "Get", "ezfSolrDocumentFieldBase", "instances", "for", "all", "attributes", "of", "specified", "eZContentObjectVersion" ]
b11eac0cee490826d5a55ec9e5642cb156b1a8ec
https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/classes/ezfsolrdocumentfieldobjectrelation.php#L342-L357
train
netgen/query-translator
lib/Languages/Galach/TokenExtractor.php
TokenExtractor.createToken
private function createToken($type, $position, array $data) { if ($type === Tokenizer::TOKEN_GROUP_BEGIN) { return $this->createGroupBeginToken($position, $data); } if ($type === Tokenizer::TOKEN_TERM) { return $this->createTermToken($position, $data); } return new Token($type, $data['lexeme'], $position); }
php
private function createToken($type, $position, array $data) { if ($type === Tokenizer::TOKEN_GROUP_BEGIN) { return $this->createGroupBeginToken($position, $data); } if ($type === Tokenizer::TOKEN_TERM) { return $this->createTermToken($position, $data); } return new Token($type, $data['lexeme'], $position); }
[ "private", "function", "createToken", "(", "$", "type", ",", "$", "position", ",", "array", "$", "data", ")", "{", "if", "(", "$", "type", "===", "Tokenizer", "::", "TOKEN_GROUP_BEGIN", ")", "{", "return", "$", "this", "->", "createGroupBeginToken", "(", ...
Create a token object from the given parameters. @param int $type Token type @param int $position Position of the token in the input string @param array $data Regex match data, depends on the type of the token @return \QueryTranslator\Values\Token
[ "Create", "a", "token", "object", "from", "the", "given", "parameters", "." ]
22710ee4a130eb5f873081fdb465c184d7f29dff
https://github.com/netgen/query-translator/blob/22710ee4a130eb5f873081fdb465c184d7f29dff/lib/Languages/Galach/TokenExtractor.php#L84-L95
train
netgen/query-translator
lib/Languages/Galach/Parser.php
Parser.reduceLogicalOr
protected function reduceLogicalOr(Node $node, $inGroup = false) { if ($this->stack->count() <= 1 || !$this->isTopStackToken(Tokenizer::TOKEN_LOGICAL_OR)) { return $node; } // If inside a group don't look for following logical AND if (!$inGroup) { $this->popWhitespace(); // If the next token is logical AND, put the node on stack // as that has precedence over logical OR if ($this->isToken(reset($this->tokens), Tokenizer::TOKEN_LOGICAL_AND)) { $this->stack->push($node); return null; } } $token = $this->stack->pop(); $leftOperand = $this->stack->pop(); return new LogicalOr($leftOperand, $node, $token); }
php
protected function reduceLogicalOr(Node $node, $inGroup = false) { if ($this->stack->count() <= 1 || !$this->isTopStackToken(Tokenizer::TOKEN_LOGICAL_OR)) { return $node; } // If inside a group don't look for following logical AND if (!$inGroup) { $this->popWhitespace(); // If the next token is logical AND, put the node on stack // as that has precedence over logical OR if ($this->isToken(reset($this->tokens), Tokenizer::TOKEN_LOGICAL_AND)) { $this->stack->push($node); return null; } } $token = $this->stack->pop(); $leftOperand = $this->stack->pop(); return new LogicalOr($leftOperand, $node, $token); }
[ "protected", "function", "reduceLogicalOr", "(", "Node", "$", "node", ",", "$", "inGroup", "=", "false", ")", "{", "if", "(", "$", "this", "->", "stack", "->", "count", "(", ")", "<=", "1", "||", "!", "$", "this", "->", "isTopStackToken", "(", "Token...
Reduce logical OR. @param \QueryTranslator\Values\Node $node @param bool $inGroup Reduce inside a group @return null|\QueryTranslator\Languages\Galach\Values\Node\LogicalOr|\QueryTranslator\Values\Node
[ "Reduce", "logical", "OR", "." ]
22710ee4a130eb5f873081fdb465c184d7f29dff
https://github.com/netgen/query-translator/blob/22710ee4a130eb5f873081fdb465c184d7f29dff/lib/Languages/Galach/Parser.php#L369-L391
train
netgen/query-translator
lib/Languages/Galach/Parser.php
Parser.collectTopStackNodes
private function collectTopStackNodes() { $nodes = []; while (!$this->stack->isEmpty() && $this->stack->top() instanceof Node) { array_unshift($nodes, $this->stack->pop()); } return $nodes; }
php
private function collectTopStackNodes() { $nodes = []; while (!$this->stack->isEmpty() && $this->stack->top() instanceof Node) { array_unshift($nodes, $this->stack->pop()); } return $nodes; }
[ "private", "function", "collectTopStackNodes", "(", ")", "{", "$", "nodes", "=", "[", "]", ";", "while", "(", "!", "$", "this", "->", "stack", "->", "isEmpty", "(", ")", "&&", "$", "this", "->", "stack", "->", "top", "(", ")", "instanceof", "Node", ...
Collect all Nodes from the top of the stack. @return \QueryTranslator\Values\Node[]
[ "Collect", "all", "Nodes", "from", "the", "top", "of", "the", "stack", "." ]
22710ee4a130eb5f873081fdb465c184d7f29dff
https://github.com/netgen/query-translator/blob/22710ee4a130eb5f873081fdb465c184d7f29dff/lib/Languages/Galach/Parser.php#L422-L431
train
netgen/query-translator
lib/Languages/Galach/Parser.php
Parser.popWhitespace
private function popWhitespace() { while ($this->isToken(reset($this->tokens), Tokenizer::TOKEN_WHITESPACE)) { array_shift($this->tokens); } }
php
private function popWhitespace() { while ($this->isToken(reset($this->tokens), Tokenizer::TOKEN_WHITESPACE)) { array_shift($this->tokens); } }
[ "private", "function", "popWhitespace", "(", ")", "{", "while", "(", "$", "this", "->", "isToken", "(", "reset", "(", "$", "this", "->", "tokens", ")", ",", "Tokenizer", "::", "TOKEN_WHITESPACE", ")", ")", "{", "array_shift", "(", "$", "this", "->", "t...
Remove whitespace Tokens from the beginning of the token array.
[ "Remove", "whitespace", "Tokens", "from", "the", "beginning", "of", "the", "token", "array", "." ]
22710ee4a130eb5f873081fdb465c184d7f29dff
https://github.com/netgen/query-translator/blob/22710ee4a130eb5f873081fdb465c184d7f29dff/lib/Languages/Galach/Parser.php#L516-L521
train
netgen/query-translator
lib/Languages/Galach/Parser.php
Parser.popTokens
private function popTokens($typeMask = null) { while ($this->isTopStackToken($typeMask)) { $token = $this->stack->pop(); if ($token->type & self::$tokenShortcuts['operatorUnary']) { $this->addCorrection( self::CORRECTION_UNARY_OPERATOR_MISSING_OPERAND_IGNORED, $token ); } else { $this->addCorrection( self::CORRECTION_BINARY_OPERATOR_MISSING_RIGHT_OPERAND_IGNORED, $token ); } } }
php
private function popTokens($typeMask = null) { while ($this->isTopStackToken($typeMask)) { $token = $this->stack->pop(); if ($token->type & self::$tokenShortcuts['operatorUnary']) { $this->addCorrection( self::CORRECTION_UNARY_OPERATOR_MISSING_OPERAND_IGNORED, $token ); } else { $this->addCorrection( self::CORRECTION_BINARY_OPERATOR_MISSING_RIGHT_OPERAND_IGNORED, $token ); } } }
[ "private", "function", "popTokens", "(", "$", "typeMask", "=", "null", ")", "{", "while", "(", "$", "this", "->", "isTopStackToken", "(", "$", "typeMask", ")", ")", "{", "$", "token", "=", "$", "this", "->", "stack", "->", "pop", "(", ")", ";", "if...
Remove all Tokens from the top of the query stack and log Corrections as necessary. Optionally also checks that Token matches given $typeMask. @param int $typeMask
[ "Remove", "all", "Tokens", "from", "the", "top", "of", "the", "query", "stack", "and", "log", "Corrections", "as", "necessary", "." ]
22710ee4a130eb5f873081fdb465c184d7f29dff
https://github.com/netgen/query-translator/blob/22710ee4a130eb5f873081fdb465c184d7f29dff/lib/Languages/Galach/Parser.php#L530-L546
train
netgen/query-translator
lib/Languages/Galach/Parser.php
Parser.reduceRemainingLogicalOr
private function reduceRemainingLogicalOr($inGroup = false) { if (!$this->stack->isEmpty() && !$this->isTopStackToken()) { $node = $this->reduceLogicalOr($this->stack->pop(), $inGroup); $this->stack->push($node); } }
php
private function reduceRemainingLogicalOr($inGroup = false) { if (!$this->stack->isEmpty() && !$this->isTopStackToken()) { $node = $this->reduceLogicalOr($this->stack->pop(), $inGroup); $this->stack->push($node); } }
[ "private", "function", "reduceRemainingLogicalOr", "(", "$", "inGroup", "=", "false", ")", "{", "if", "(", "!", "$", "this", "->", "stack", "->", "isEmpty", "(", ")", "&&", "!", "$", "this", "->", "isTopStackToken", "(", ")", ")", "{", "$", "node", "...
Reduce logical OR possibly remaining after reaching end of group or query. @param bool $inGroup Reduce inside a group
[ "Reduce", "logical", "OR", "possibly", "remaining", "after", "reaching", "end", "of", "group", "or", "query", "." ]
22710ee4a130eb5f873081fdb465c184d7f29dff
https://github.com/netgen/query-translator/blob/22710ee4a130eb5f873081fdb465c184d7f29dff/lib/Languages/Galach/Parser.php#L577-L583
train
netgen/query-translator
lib/Languages/Galach/Parser.php
Parser.cleanupGroupDelimiters
private function cleanupGroupDelimiters(array &$tokens) { $indexes = $this->getUnmatchedGroupDelimiterIndexes($tokens); while (!empty($indexes)) { $lastIndex = array_pop($indexes); $token = $tokens[$lastIndex]; unset($tokens[$lastIndex]); if ($token->type === Tokenizer::TOKEN_GROUP_BEGIN) { $this->addCorrection( self::CORRECTION_UNMATCHED_GROUP_LEFT_DELIMITER_IGNORED, $token ); } else { $this->addCorrection( self::CORRECTION_UNMATCHED_GROUP_RIGHT_DELIMITER_IGNORED, $token ); } } }
php
private function cleanupGroupDelimiters(array &$tokens) { $indexes = $this->getUnmatchedGroupDelimiterIndexes($tokens); while (!empty($indexes)) { $lastIndex = array_pop($indexes); $token = $tokens[$lastIndex]; unset($tokens[$lastIndex]); if ($token->type === Tokenizer::TOKEN_GROUP_BEGIN) { $this->addCorrection( self::CORRECTION_UNMATCHED_GROUP_LEFT_DELIMITER_IGNORED, $token ); } else { $this->addCorrection( self::CORRECTION_UNMATCHED_GROUP_RIGHT_DELIMITER_IGNORED, $token ); } } }
[ "private", "function", "cleanupGroupDelimiters", "(", "array", "&", "$", "tokens", ")", "{", "$", "indexes", "=", "$", "this", "->", "getUnmatchedGroupDelimiterIndexes", "(", "$", "tokens", ")", ";", "while", "(", "!", "empty", "(", "$", "indexes", ")", ")...
Clean up group delimiter tokens, removing unmatched left and right delimiter. Closest group delimiters will be matched first, unmatched remainder is removed. @param \QueryTranslator\Values\Token[] $tokens
[ "Clean", "up", "group", "delimiter", "tokens", "removing", "unmatched", "left", "and", "right", "delimiter", "." ]
22710ee4a130eb5f873081fdb465c184d7f29dff
https://github.com/netgen/query-translator/blob/22710ee4a130eb5f873081fdb465c184d7f29dff/lib/Languages/Galach/Parser.php#L592-L613
train
BoltApp/bolt-magento2
Helper/Session.php
Session.saveSession
public function saveSession($qouoteId, $checkoutSession) { // cache the session id by (parent) quote id $cacheIdentifier = self::BOLT_SESSION_PREFIX . $qouoteId; $sessionData = [ "sessionType" => $checkoutSession instanceof \Magento\Checkout\Model\Session ? "frontend" : "admin", "sessionID" => $checkoutSession->getSessionId() ]; $this->cache->save(serialize($sessionData), $cacheIdentifier, [], 86400); }
php
public function saveSession($qouoteId, $checkoutSession) { // cache the session id by (parent) quote id $cacheIdentifier = self::BOLT_SESSION_PREFIX . $qouoteId; $sessionData = [ "sessionType" => $checkoutSession instanceof \Magento\Checkout\Model\Session ? "frontend" : "admin", "sessionID" => $checkoutSession->getSessionId() ]; $this->cache->save(serialize($sessionData), $cacheIdentifier, [], 86400); }
[ "public", "function", "saveSession", "(", "$", "qouoteId", ",", "$", "checkoutSession", ")", "{", "// cache the session id by (parent) quote id", "$", "cacheIdentifier", "=", "self", "::", "BOLT_SESSION_PREFIX", ".", "$", "qouoteId", ";", "$", "sessionData", "=", "[...
Cache the session id for the quote @param int|string $qouoteId @param mixed $checkoutSession
[ "Cache", "the", "session", "id", "for", "the", "quote" ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Session.php#L94-L103
train
BoltApp/bolt-magento2
Helper/Session.php
Session.setSession
private function setSession($session, $sessionID) { // close current session $session->writeClose(); // set session id (to value loaded from cache) $session->setSessionId($sessionID); // re-start the session $session->start(); }
php
private function setSession($session, $sessionID) { // close current session $session->writeClose(); // set session id (to value loaded from cache) $session->setSessionId($sessionID); // re-start the session $session->start(); }
[ "private", "function", "setSession", "(", "$", "session", ",", "$", "sessionID", ")", "{", "// close current session", "$", "session", "->", "writeClose", "(", ")", ";", "// set session id (to value loaded from cache)", "$", "session", "->", "setSessionId", "(", "$"...
Emulate session from cached session id @param mixed $session @param string $sessionID
[ "Emulate", "session", "from", "cached", "session", "id" ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Session.php#L111-L119
train
BoltApp/bolt-magento2
Helper/Session.php
Session.loadSession
public function loadSession($quote) { // not an API call, no need to emulate session if ($this->appState->getAreaCode() != \Magento\Framework\App\Area::AREA_WEBAPI_REST) { $this->replaceQuote($quote); return; } $customerId = $quote->getCustomerId(); $cacheIdentifier = self::BOLT_SESSION_PREFIX . $quote->getBoltParentQuoteId(); if ($serialized = $this->cache->load($cacheIdentifier)) { $sessionData = unserialize($serialized); $sessionID = $sessionData["sessionID"]; if ($sessionData["sessionType"] == "frontend") { // shipping and tax, orphaned transaction // cart belongs to logged in customer? if ($customerId) { $this->setSession($this->checkoutSession, $sessionID); $this->setSession($this->customerSession, $sessionID); } } else { // orphaned transaction $this->setSession($this->adminCheckoutSession, $sessionID); } } if ($customerId) { $this->customerSession->loginById($customerId); } $this->replaceQuote($quote); }
php
public function loadSession($quote) { // not an API call, no need to emulate session if ($this->appState->getAreaCode() != \Magento\Framework\App\Area::AREA_WEBAPI_REST) { $this->replaceQuote($quote); return; } $customerId = $quote->getCustomerId(); $cacheIdentifier = self::BOLT_SESSION_PREFIX . $quote->getBoltParentQuoteId(); if ($serialized = $this->cache->load($cacheIdentifier)) { $sessionData = unserialize($serialized); $sessionID = $sessionData["sessionID"]; if ($sessionData["sessionType"] == "frontend") { // shipping and tax, orphaned transaction // cart belongs to logged in customer? if ($customerId) { $this->setSession($this->checkoutSession, $sessionID); $this->setSession($this->customerSession, $sessionID); } } else { // orphaned transaction $this->setSession($this->adminCheckoutSession, $sessionID); } } if ($customerId) { $this->customerSession->loginById($customerId); } $this->replaceQuote($quote); }
[ "public", "function", "loadSession", "(", "$", "quote", ")", "{", "// not an API call, no need to emulate session", "if", "(", "$", "this", "->", "appState", "->", "getAreaCode", "(", ")", "!=", "\\", "Magento", "\\", "Framework", "\\", "App", "\\", "Area", ":...
Load logged in customer checkout and customer sessions from cached session id. Replace parent quote with immutable quote in checkout session. @param Quote $quote @throws \Magento\Framework\Exception\SessionException
[ "Load", "logged", "in", "customer", "checkout", "and", "customer", "sessions", "from", "cached", "session", "id", ".", "Replace", "parent", "quote", "with", "immutable", "quote", "in", "checkout", "session", "." ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Session.php#L137-L169
train
BoltApp/bolt-magento2
Helper/Bugsnag.php
Bugsnag.addCommonMetaData
private function addCommonMetaData() { $this->bugsnag->registerCallback(function ($report) { $report->addMetaData([ 'META DATA' => [ 'store_url' => $this->storeManager->getStore()->getBaseUrl( \Magento\Framework\UrlInterface::URL_TYPE_WEB ) ] ]); }); }
php
private function addCommonMetaData() { $this->bugsnag->registerCallback(function ($report) { $report->addMetaData([ 'META DATA' => [ 'store_url' => $this->storeManager->getStore()->getBaseUrl( \Magento\Framework\UrlInterface::URL_TYPE_WEB ) ] ]); }); }
[ "private", "function", "addCommonMetaData", "(", ")", "{", "$", "this", "->", "bugsnag", "->", "registerCallback", "(", "function", "(", "$", "report", ")", "{", "$", "report", "->", "addMetaData", "(", "[", "'META DATA'", "=>", "[", "'store_url'", "=>", "...
Add metadata to every bugsnag log
[ "Add", "metadata", "to", "every", "bugsnag", "log" ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Bugsnag.php#L144-L155
train
BoltApp/bolt-magento2
Helper/Config.php
Config.getCdnUrl
public function getCdnUrl($storeId = null) { //Check for sandbox mode if ($this->isSandboxModeSet($storeId)) { return self::CDN_URL_SANDBOX; } else { return self::CDN_URL_PRODUCTION; } }
php
public function getCdnUrl($storeId = null) { //Check for sandbox mode if ($this->isSandboxModeSet($storeId)) { return self::CDN_URL_SANDBOX; } else { return self::CDN_URL_PRODUCTION; } }
[ "public", "function", "getCdnUrl", "(", "$", "storeId", "=", "null", ")", "{", "//Check for sandbox mode", "if", "(", "$", "this", "->", "isSandboxModeSet", "(", "$", "storeId", ")", ")", "{", "return", "self", "::", "CDN_URL_SANDBOX", ";", "}", "else", "{...
Get Bolt JavaScript base URL @param int|string $storeId @return string
[ "Get", "Bolt", "JavaScript", "base", "URL" ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Config.php#L324-L332
train
BoltApp/bolt-magento2
Helper/Config.php
Config.getEncryptedKey
private function getEncryptedKey($path, $storeId = null) { //Get management key $key = $this->getScopeConfig()->getValue( $path, ScopeInterface::SCOPE_STORE, $storeId ); //Decrypt management key $key = $this->encryptor->decrypt($key); return $key; }
php
private function getEncryptedKey($path, $storeId = null) { //Get management key $key = $this->getScopeConfig()->getValue( $path, ScopeInterface::SCOPE_STORE, $storeId ); //Decrypt management key $key = $this->encryptor->decrypt($key); return $key; }
[ "private", "function", "getEncryptedKey", "(", "$", "path", ",", "$", "storeId", "=", "null", ")", "{", "//Get management key", "$", "key", "=", "$", "this", "->", "getScopeConfig", "(", ")", "->", "getValue", "(", "$", "path", ",", "ScopeInterface", "::",...
Helper method to Get Encrypted Key from config. Return decrypted. @param string $path @param int|string $storeId @return string
[ "Helper", "method", "to", "Get", "Encrypted", "Key", "from", "config", ".", "Return", "decrypted", "." ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Config.php#L361-L373
train
BoltApp/bolt-magento2
Helper/Config.php
Config.getTotalsChangeSelectors
public function getTotalsChangeSelectors($storeId = null) { return $this->getScopeConfig()->getValue( self::XML_PATH_TOTALS_CHANGE_SELECTORS, ScopeInterface::SCOPE_STORE, $storeId ); }
php
public function getTotalsChangeSelectors($storeId = null) { return $this->getScopeConfig()->getValue( self::XML_PATH_TOTALS_CHANGE_SELECTORS, ScopeInterface::SCOPE_STORE, $storeId ); }
[ "public", "function", "getTotalsChangeSelectors", "(", "$", "storeId", "=", "null", ")", "{", "return", "$", "this", "->", "getScopeConfig", "(", ")", "->", "getValue", "(", "self", "::", "XML_PATH_TOTALS_CHANGE_SELECTORS", ",", "ScopeInterface", "::", "SCOPE_STOR...
Get Totals Change Selectors from config @param int|string $storeId @return string
[ "Get", "Totals", "Change", "Selectors", "from", "config" ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Config.php#L470-L477
train
BoltApp/bolt-magento2
Helper/Config.php
Config.getAdditionalCheckoutButtonClass
public function getAdditionalCheckoutButtonClass($storeId = null) { return $this->getScopeConfig()->getValue( self::XML_PATH_ADDITIONAL_CHECKOUT_BUTTON_CLASS, ScopeInterface::SCOPE_STORE, $storeId ); }
php
public function getAdditionalCheckoutButtonClass($storeId = null) { return $this->getScopeConfig()->getValue( self::XML_PATH_ADDITIONAL_CHECKOUT_BUTTON_CLASS, ScopeInterface::SCOPE_STORE, $storeId ); }
[ "public", "function", "getAdditionalCheckoutButtonClass", "(", "$", "storeId", "=", "null", ")", "{", "return", "$", "this", "->", "getScopeConfig", "(", ")", "->", "getValue", "(", "self", "::", "XML_PATH_ADDITIONAL_CHECKOUT_BUTTON_CLASS", ",", "ScopeInterface", ":...
Get additional checkout button class @param int|string $storeId @return string
[ "Get", "additional", "checkout", "button", "class" ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Config.php#L502-L509
train
BoltApp/bolt-magento2
Helper/Config.php
Config.getPrefetchAddressFields
public function getPrefetchAddressFields($storeId = null) { return $this->getScopeConfig()->getValue( self::XML_PATH_PREFETCH_ADDRESS_FIELDS, ScopeInterface::SCOPE_STORE, $storeId ); }
php
public function getPrefetchAddressFields($storeId = null) { return $this->getScopeConfig()->getValue( self::XML_PATH_PREFETCH_ADDRESS_FIELDS, ScopeInterface::SCOPE_STORE, $storeId ); }
[ "public", "function", "getPrefetchAddressFields", "(", "$", "storeId", "=", "null", ")", "{", "return", "$", "this", "->", "getScopeConfig", "(", ")", "->", "getValue", "(", "self", "::", "XML_PATH_PREFETCH_ADDRESS_FIELDS", ",", "ScopeInterface", "::", "SCOPE_STOR...
Get Custom Prefetch Address Fields @param int|string $storeId @return string
[ "Get", "Custom", "Prefetch", "Address", "Fields" ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Config.php#L518-L525
train
BoltApp/bolt-magento2
Helper/Config.php
Config.getSuccessPageRedirect
public function getSuccessPageRedirect($storeId = null) { return $this->getScopeConfig()->getValue( self::XML_PATH_SUCCESS_PAGE_REDIRECT, ScopeInterface::SCOPE_STORE, $storeId ); }
php
public function getSuccessPageRedirect($storeId = null) { return $this->getScopeConfig()->getValue( self::XML_PATH_SUCCESS_PAGE_REDIRECT, ScopeInterface::SCOPE_STORE, $storeId ); }
[ "public", "function", "getSuccessPageRedirect", "(", "$", "storeId", "=", "null", ")", "{", "return", "$", "this", "->", "getScopeConfig", "(", ")", "->", "getValue", "(", "self", "::", "XML_PATH_SUCCESS_PAGE_REDIRECT", ",", "ScopeInterface", "::", "SCOPE_STORE", ...
Get Success Page Redirect from config @param int|string $storeId @return string
[ "Get", "Success", "Page", "Redirect", "from", "config" ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Config.php#L534-L541
train
BoltApp/bolt-magento2
Helper/Config.php
Config.getJavascriptSuccess
public function getJavascriptSuccess($storeId = null) { return $this->getScopeConfig()->getValue( self::XML_PATH_JAVASCRIPT_SUCCESS, ScopeInterface::SCOPE_STORE, $storeId ); }
php
public function getJavascriptSuccess($storeId = null) { return $this->getScopeConfig()->getValue( self::XML_PATH_JAVASCRIPT_SUCCESS, ScopeInterface::SCOPE_STORE, $storeId ); }
[ "public", "function", "getJavascriptSuccess", "(", "$", "storeId", "=", "null", ")", "{", "return", "$", "this", "->", "getScopeConfig", "(", ")", "->", "getValue", "(", "self", "::", "XML_PATH_JAVASCRIPT_SUCCESS", ",", "ScopeInterface", "::", "SCOPE_STORE", ","...
Get Custom javascript function call on success @param int|string $storeId @return string
[ "Get", "Custom", "javascript", "function", "call", "on", "success" ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Config.php#L550-L557
train
BoltApp/bolt-magento2
Helper/Config.php
Config.getAutomaticCaptureMode
public function getAutomaticCaptureMode($store = null) { return $this->getScopeConfig()->isSetFlag( self::XML_PATH_AUTOMATIC_CAPTURE_MODE, ScopeInterface::SCOPE_STORE, $store ); }
php
public function getAutomaticCaptureMode($store = null) { return $this->getScopeConfig()->isSetFlag( self::XML_PATH_AUTOMATIC_CAPTURE_MODE, ScopeInterface::SCOPE_STORE, $store ); }
[ "public", "function", "getAutomaticCaptureMode", "(", "$", "store", "=", "null", ")", "{", "return", "$", "this", "->", "getScopeConfig", "(", ")", "->", "isSetFlag", "(", "self", "::", "XML_PATH_AUTOMATIC_CAPTURE_MODE", ",", "ScopeInterface", "::", "SCOPE_STORE",...
Get Automatic Capture mode from config @param int|string|Store $store @return boolean
[ "Get", "Automatic", "Capture", "mode", "from", "config" ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Config.php#L566-L573
train
BoltApp/bolt-magento2
Helper/Config.php
Config.getPrefetchShipping
public function getPrefetchShipping($store = null) { return $this->getScopeConfig()->isSetFlag( self::XML_PATH_PREFETCH_SHIPPING, ScopeInterface::SCOPE_STORE, $store ); }
php
public function getPrefetchShipping($store = null) { return $this->getScopeConfig()->isSetFlag( self::XML_PATH_PREFETCH_SHIPPING, ScopeInterface::SCOPE_STORE, $store ); }
[ "public", "function", "getPrefetchShipping", "(", "$", "store", "=", "null", ")", "{", "return", "$", "this", "->", "getScopeConfig", "(", ")", "->", "isSetFlag", "(", "self", "::", "XML_PATH_PREFETCH_SHIPPING", ",", "ScopeInterface", "::", "SCOPE_STORE", ",", ...
Get Prefetch Shipping and Tax config @param int|string|Store $store @return boolean
[ "Get", "Prefetch", "Shipping", "and", "Tax", "config" ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Config.php#L582-L589
train
BoltApp/bolt-magento2
Helper/Config.php
Config.getResetShippingCalculation
public function getResetShippingCalculation($store = null) { return $this->getScopeConfig()->isSetFlag( self::XML_PATH_RESET_SHIPPING_CALCULATION, ScopeInterface::SCOPE_STORE, $store ); }
php
public function getResetShippingCalculation($store = null) { return $this->getScopeConfig()->isSetFlag( self::XML_PATH_RESET_SHIPPING_CALCULATION, ScopeInterface::SCOPE_STORE, $store ); }
[ "public", "function", "getResetShippingCalculation", "(", "$", "store", "=", "null", ")", "{", "return", "$", "this", "->", "getScopeConfig", "(", ")", "->", "isSetFlag", "(", "self", "::", "XML_PATH_RESET_SHIPPING_CALCULATION", ",", "ScopeInterface", "::", "SCOPE...
Get Reset Shipping Calculation config @param int|string|Store $store @return boolean
[ "Get", "Reset", "Shipping", "Calculation", "config" ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Config.php#L598-L605
train
BoltApp/bolt-magento2
Helper/Config.php
Config.isActive
public function isActive($store = null) { return $this->getScopeConfig()->isSetFlag( self::XML_PATH_ACTIVE, ScopeInterface::SCOPE_STORE, $store ); }
php
public function isActive($store = null) { return $this->getScopeConfig()->isSetFlag( self::XML_PATH_ACTIVE, ScopeInterface::SCOPE_STORE, $store ); }
[ "public", "function", "isActive", "(", "$", "store", "=", "null", ")", "{", "return", "$", "this", "->", "getScopeConfig", "(", ")", "->", "isSetFlag", "(", "self", "::", "XML_PATH_ACTIVE", ",", "ScopeInterface", "::", "SCOPE_STORE", ",", "$", "store", ")"...
Check if module is enabled @param int|string|Store $store @return boolean
[ "Check", "if", "module", "is", "enabled" ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Config.php#L614-L621
train
BoltApp/bolt-magento2
Helper/Config.php
Config.isDebugModeOn
public function isDebugModeOn($store = null) { return $this->getScopeConfig()->isSetFlag( self::XML_PATH_DEBUG, ScopeInterface::SCOPE_STORE, $store ); }
php
public function isDebugModeOn($store = null) { return $this->getScopeConfig()->isSetFlag( self::XML_PATH_DEBUG, ScopeInterface::SCOPE_STORE, $store ); }
[ "public", "function", "isDebugModeOn", "(", "$", "store", "=", "null", ")", "{", "return", "$", "this", "->", "getScopeConfig", "(", ")", "->", "isSetFlag", "(", "self", "::", "XML_PATH_DEBUG", ",", "ScopeInterface", "::", "SCOPE_STORE", ",", "$", "store", ...
Check if debug mode is on @param int|string|Store $store @return boolean
[ "Check", "if", "debug", "mode", "is", "on" ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Config.php#L630-L637
train
BoltApp/bolt-magento2
Helper/Config.php
Config.isSandboxModeSet
public function isSandboxModeSet($store = null) { return $this->getScopeConfig()->isSetFlag( self::XML_PATH_SANDBOX_MODE, ScopeInterface::SCOPE_STORE, $store ); }
php
public function isSandboxModeSet($store = null) { return $this->getScopeConfig()->isSetFlag( self::XML_PATH_SANDBOX_MODE, ScopeInterface::SCOPE_STORE, $store ); }
[ "public", "function", "isSandboxModeSet", "(", "$", "store", "=", "null", ")", "{", "return", "$", "this", "->", "getScopeConfig", "(", ")", "->", "isSetFlag", "(", "self", "::", "XML_PATH_SANDBOX_MODE", ",", "ScopeInterface", "::", "SCOPE_STORE", ",", "$", ...
Get sandbox mode config value @param int|string|Store $store @return bool @SuppressWarnings(PHPMD.BooleanGetMethodName) @codeCoverageIgnore
[ "Get", "sandbox", "mode", "config", "value" ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Config.php#L648-L655
train
BoltApp/bolt-magento2
Helper/Config.php
Config.getAdditionalJS
public function getAdditionalJS($storeId = null) { return $this->getScopeConfig()->getValue( self::XML_PATH_ADDITIONAL_JS, ScopeInterface::SCOPE_STORE, $storeId ); }
php
public function getAdditionalJS($storeId = null) { return $this->getScopeConfig()->getValue( self::XML_PATH_ADDITIONAL_JS, ScopeInterface::SCOPE_STORE, $storeId ); }
[ "public", "function", "getAdditionalJS", "(", "$", "storeId", "=", "null", ")", "{", "return", "$", "this", "->", "getScopeConfig", "(", ")", "->", "getValue", "(", "self", "::", "XML_PATH_ADDITIONAL_JS", ",", "ScopeInterface", "::", "SCOPE_STORE", ",", "$", ...
Get Additional Javascript from config @param int|string $storeId @return string
[ "Get", "Additional", "Javascript", "from", "config" ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Config.php#L684-L691
train
BoltApp/bolt-magento2
Helper/Config.php
Config.getAdditionalConfigString
protected function getAdditionalConfigString($storeId = null) { return $this->getScopeConfig()->getValue( self::XML_PATH_ADDITIONAL_CONFIG, ScopeInterface::SCOPE_STORE, $storeId ) ?: '{}'; }
php
protected function getAdditionalConfigString($storeId = null) { return $this->getScopeConfig()->getValue( self::XML_PATH_ADDITIONAL_CONFIG, ScopeInterface::SCOPE_STORE, $storeId ) ?: '{}'; }
[ "protected", "function", "getAdditionalConfigString", "(", "$", "storeId", "=", "null", ")", "{", "return", "$", "this", "->", "getScopeConfig", "(", ")", "->", "getValue", "(", "self", "::", "XML_PATH_ADDITIONAL_CONFIG", ",", "ScopeInterface", "::", "SCOPE_STORE"...
Get Additional Config string @param int|string $storeId @return string
[ "Get", "Additional", "Config", "string" ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Config.php#L795-L802
train
BoltApp/bolt-magento2
Helper/Config.php
Config.getAdditionalConfigProperty
private function getAdditionalConfigProperty($name, $storeId = null) { $config = $this->getAdditionalConfigObject($storeId); return @$config->$name; // return ($config && property_exists($config, $name)) ? $config->$name: ''; }
php
private function getAdditionalConfigProperty($name, $storeId = null) { $config = $this->getAdditionalConfigObject($storeId); return @$config->$name; // return ($config && property_exists($config, $name)) ? $config->$name: ''; }
[ "private", "function", "getAdditionalConfigProperty", "(", "$", "name", ",", "$", "storeId", "=", "null", ")", "{", "$", "config", "=", "$", "this", "->", "getAdditionalConfigObject", "(", "$", "storeId", ")", ";", "return", "@", "$", "config", "->", "$", ...
Get Additional Config property @param $name @param int|string $storeId @return string
[ "Get", "Additional", "Config", "property" ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Config.php#L824-L829
train
BoltApp/bolt-magento2
Helper/Config.php
Config.getMinicartSupport
public function getMinicartSupport($store = null) { return $this->getScopeConfig()->isSetFlag( self::XML_PATH_MINICART_SUPPORT, ScopeInterface::SCOPE_STORE, $store ); }
php
public function getMinicartSupport($store = null) { return $this->getScopeConfig()->isSetFlag( self::XML_PATH_MINICART_SUPPORT, ScopeInterface::SCOPE_STORE, $store ); }
[ "public", "function", "getMinicartSupport", "(", "$", "store", "=", "null", ")", "{", "return", "$", "this", "->", "getScopeConfig", "(", ")", "->", "isSetFlag", "(", "self", "::", "XML_PATH_MINICART_SUPPORT", ",", "ScopeInterface", "::", "SCOPE_STORE", ",", "...
Get MiniCart Support config @param int|string|Store $store @return boolean
[ "Get", "MiniCart", "Support", "config" ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Config.php#L892-L899
train
BoltApp/bolt-magento2
Helper/Config.php
Config.getPageFilter
private function getPageFilter($filterName, $storeId = null) { $pageFilters = $this->getPageFilters($storeId); if ($pageFilters && @$pageFilters->$filterName) { return (array)$pageFilters->$filterName; } return []; }
php
private function getPageFilter($filterName, $storeId = null) { $pageFilters = $this->getPageFilters($storeId); if ($pageFilters && @$pageFilters->$filterName) { return (array)$pageFilters->$filterName; } return []; }
[ "private", "function", "getPageFilter", "(", "$", "filterName", ",", "$", "storeId", "=", "null", ")", "{", "$", "pageFilters", "=", "$", "this", "->", "getPageFilters", "(", "$", "storeId", ")", ";", "if", "(", "$", "pageFilters", "&&", "@", "$", "pag...
Get filter specified by name from "pageFilters" additional configuration @param string $filterName 'whitelist'|'blacklist' @param int|string $storeId @return array
[ "Get", "filter", "specified", "by", "name", "from", "pageFilters", "additional", "configuration" ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Config.php#L927-L934
train
BoltApp/bolt-magento2
Helper/Config.php
Config.getIPWhitelistConfig
private function getIPWhitelistConfig($storeId = null) { return $this->getScopeConfig()->getValue( self::XML_PATH_IP_WHITELIST, ScopeInterface::SCOPE_STORE, $storeId ); }
php
private function getIPWhitelistConfig($storeId = null) { return $this->getScopeConfig()->getValue( self::XML_PATH_IP_WHITELIST, ScopeInterface::SCOPE_STORE, $storeId ); }
[ "private", "function", "getIPWhitelistConfig", "(", "$", "storeId", "=", "null", ")", "{", "return", "$", "this", "->", "getScopeConfig", "(", ")", "->", "getValue", "(", "self", "::", "XML_PATH_IP_WHITELIST", ",", "ScopeInterface", "::", "SCOPE_STORE", ",", "...
Get Client IP Whitelist from config @param int|string $storeId @return string
[ "Get", "Client", "IP", "Whitelist", "from", "config" ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Config.php#L986-L993
train
BoltApp/bolt-magento2
Helper/Config.php
Config.isIPRestricted
public function isIPRestricted($storeId = null) { $clientIP = $this->getClientIp(); $whitelist = $this->getIPWhitelistArray($storeId); return $whitelist && ! in_array($clientIP, $whitelist); }
php
public function isIPRestricted($storeId = null) { $clientIP = $this->getClientIp(); $whitelist = $this->getIPWhitelistArray($storeId); return $whitelist && ! in_array($clientIP, $whitelist); }
[ "public", "function", "isIPRestricted", "(", "$", "storeId", "=", "null", ")", "{", "$", "clientIP", "=", "$", "this", "->", "getClientIp", "(", ")", ";", "$", "whitelist", "=", "$", "this", "->", "getIPWhitelistArray", "(", "$", "storeId", ")", ";", "...
Check if the client IP is restricted - there is an IP whitelist and the client IP is not on the list. @return bool
[ "Check", "if", "the", "client", "IP", "is", "restricted", "-", "there", "is", "an", "IP", "whitelist", "and", "the", "client", "IP", "is", "not", "on", "the", "list", "." ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Config.php#L1038-L1043
train
BoltApp/bolt-magento2
Helper/Config.php
Config.useStoreCreditConfig
public function useStoreCreditConfig($store = null) { return $this->getScopeConfig()->isSetFlag( self::XML_PATH_STORE_CREDIT, ScopeInterface::SCOPE_STORE, $store ); }
php
public function useStoreCreditConfig($store = null) { return $this->getScopeConfig()->isSetFlag( self::XML_PATH_STORE_CREDIT, ScopeInterface::SCOPE_STORE, $store ); }
[ "public", "function", "useStoreCreditConfig", "(", "$", "store", "=", "null", ")", "{", "return", "$", "this", "->", "getScopeConfig", "(", ")", "->", "isSetFlag", "(", "self", "::", "XML_PATH_STORE_CREDIT", ",", "ScopeInterface", "::", "SCOPE_STORE", ",", "$"...
Get Use Store Credit on Shopping Cart configuration @param int|string|Store $store @return bool
[ "Get", "Use", "Store", "Credit", "on", "Shopping", "Cart", "configuration" ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Config.php#L1051-L1058
train
BoltApp/bolt-magento2
Helper/Config.php
Config.isPaymentOnlyCheckoutEnabled
public function isPaymentOnlyCheckoutEnabled($store = null) { return $this->getScopeConfig()->isSetFlag( self::XML_PATH_PAYMENT_ONLY_CHECKOUT, ScopeInterface::SCOPE_STORE, $store ); }
php
public function isPaymentOnlyCheckoutEnabled($store = null) { return $this->getScopeConfig()->isSetFlag( self::XML_PATH_PAYMENT_ONLY_CHECKOUT, ScopeInterface::SCOPE_STORE, $store ); }
[ "public", "function", "isPaymentOnlyCheckoutEnabled", "(", "$", "store", "=", "null", ")", "{", "return", "$", "this", "->", "getScopeConfig", "(", ")", "->", "isSetFlag", "(", "self", "::", "XML_PATH_PAYMENT_ONLY_CHECKOUT", ",", "ScopeInterface", "::", "SCOPE_STO...
Get Payment Only Checkout Enabled configuration @param int|string|Store $store @return bool
[ "Get", "Payment", "Only", "Checkout", "Enabled", "configuration" ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Config.php#L1066-L1073
train
BoltApp/bolt-magento2
Model/Api/Data/ShippingOptions.php
ShippingOptions.addAmountToShippingOptions
public function addAmountToShippingOptions($amount){ foreach ($this->getShippingOptions() as $option) { $option->setCost($option->getCost() + $amount); } return $this; }
php
public function addAmountToShippingOptions($amount){ foreach ($this->getShippingOptions() as $option) { $option->setCost($option->getCost() + $amount); } return $this; }
[ "public", "function", "addAmountToShippingOptions", "(", "$", "amount", ")", "{", "foreach", "(", "$", "this", "->", "getShippingOptions", "(", ")", "as", "$", "option", ")", "{", "$", "option", "->", "setCost", "(", "$", "option", "->", "getCost", "(", ...
Add amount to shipping options. @api @param int $amount @return $this
[ "Add", "amount", "to", "shipping", "options", "." ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Model/Api/Data/ShippingOptions.php#L98-L104
train
BoltApp/bolt-magento2
Model/Api/DiscountCodeValidation.php
DiscountCodeValidation.loadGiftCardData
public function loadGiftCardData($code) { $result = null; /** @var \Magento\GiftCardAccount\Model\ResourceModel\Giftcardaccount\Collection $giftCardAccount */ $giftCardAccountResource = $this->moduleGiftCardAccount->getInstance(); if ($giftCardAccountResource) { $this->logHelper->addInfoLog('### GiftCard ###'); $this->logHelper->addInfoLog('# Code: ' . $code); /** @var \Magento\GiftCardAccount\Model\ResourceModel\Giftcardaccount\Collection $giftCardsCollection */ $giftCardsCollection = $giftCardAccountResource ->addFieldToFilter('code', ['eq' => $code]); /** @var \Magento\GiftCardAccount\Model\Giftcardaccount $giftCard */ $giftCard = $giftCardsCollection->getFirstItem(); $result = (!$giftCard->isEmpty() && $giftCard->isValid()) ? $giftCard : null; } $this->logHelper->addInfoLog('# loadGiftCertData Result is empty: '. ((!$result) ? 'yes' : 'no')); return $result; }
php
public function loadGiftCardData($code) { $result = null; /** @var \Magento\GiftCardAccount\Model\ResourceModel\Giftcardaccount\Collection $giftCardAccount */ $giftCardAccountResource = $this->moduleGiftCardAccount->getInstance(); if ($giftCardAccountResource) { $this->logHelper->addInfoLog('### GiftCard ###'); $this->logHelper->addInfoLog('# Code: ' . $code); /** @var \Magento\GiftCardAccount\Model\ResourceModel\Giftcardaccount\Collection $giftCardsCollection */ $giftCardsCollection = $giftCardAccountResource ->addFieldToFilter('code', ['eq' => $code]); /** @var \Magento\GiftCardAccount\Model\Giftcardaccount $giftCard */ $giftCard = $giftCardsCollection->getFirstItem(); $result = (!$giftCard->isEmpty() && $giftCard->isValid()) ? $giftCard : null; } $this->logHelper->addInfoLog('# loadGiftCertData Result is empty: '. ((!$result) ? 'yes' : 'no')); return $result; }
[ "public", "function", "loadGiftCardData", "(", "$", "code", ")", "{", "$", "result", "=", "null", ";", "/** @var \\Magento\\GiftCardAccount\\Model\\ResourceModel\\Giftcardaccount\\Collection $giftCardAccount */", "$", "giftCardAccountResource", "=", "$", "this", "->", "module...
Load the gift card data by code @param $code @return \Magento\GiftCardAccount\Model\Giftcardaccount|null
[ "Load", "the", "gift", "card", "data", "by", "code" ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Model/Api/DiscountCodeValidation.php#L781-L805
train
BoltApp/bolt-magento2
Block/Form.php
Form.getBillingAddress
public function getBillingAddress($needJsonEncode = true) { $quote = $this->getQuoteData(); /** @var \Magento\Quote\Model\Quote\Address $billingAddress */ $billingAddress = $quote->getBillingAddress(); $streetAddressLines = []; $streetAddressLines[] = $billingAddress->getStreetLine(1); if ($billingAddress->getStreetLine(2)) { $streetAddressLines[] = $billingAddress->getStreetLine(2); } $result = [ 'customerAddressId' => $billingAddress->getId(), 'countryId' => $billingAddress->getCountryId(), 'regionId' => $billingAddress->getRegionId(), 'regionCode' => $billingAddress->getRegionCode(), 'region' => $billingAddress->getRegion(), 'customerId' => $billingAddress->getCustomerId(), 'street' => $streetAddressLines, 'telephone' => $billingAddress->getTelephone(), 'postcode' => $billingAddress->getPostcode(), 'city' => $billingAddress->getCity(), 'firstname' => $billingAddress->getFirstname(), 'lastname' => $billingAddress->getLastname(), 'extensionAttributes' => ['checkoutFields' => []], 'saveInAddressBook' => $billingAddress->getSaveInAddressBook() ]; return ($needJsonEncode) ? json_encode($result) : $result; }
php
public function getBillingAddress($needJsonEncode = true) { $quote = $this->getQuoteData(); /** @var \Magento\Quote\Model\Quote\Address $billingAddress */ $billingAddress = $quote->getBillingAddress(); $streetAddressLines = []; $streetAddressLines[] = $billingAddress->getStreetLine(1); if ($billingAddress->getStreetLine(2)) { $streetAddressLines[] = $billingAddress->getStreetLine(2); } $result = [ 'customerAddressId' => $billingAddress->getId(), 'countryId' => $billingAddress->getCountryId(), 'regionId' => $billingAddress->getRegionId(), 'regionCode' => $billingAddress->getRegionCode(), 'region' => $billingAddress->getRegion(), 'customerId' => $billingAddress->getCustomerId(), 'street' => $streetAddressLines, 'telephone' => $billingAddress->getTelephone(), 'postcode' => $billingAddress->getPostcode(), 'city' => $billingAddress->getCity(), 'firstname' => $billingAddress->getFirstname(), 'lastname' => $billingAddress->getLastname(), 'extensionAttributes' => ['checkoutFields' => []], 'saveInAddressBook' => $billingAddress->getSaveInAddressBook() ]; return ($needJsonEncode) ? json_encode($result) : $result; }
[ "public", "function", "getBillingAddress", "(", "$", "needJsonEncode", "=", "true", ")", "{", "$", "quote", "=", "$", "this", "->", "getQuoteData", "(", ")", ";", "/** @var \\Magento\\Quote\\Model\\Quote\\Address $billingAddress */", "$", "billingAddress", "=", "$", ...
Return billing address information formatted to be used for magento order creation. Example return value: {"customerAddressId":"404","countryId":"US","regionId":"12","regionCode":"CA","region":"California", "customerId":"202","street":["adasdasd 1234"],"telephone":"314-123-4125","postcode":"90014", "city":"Los Angeles","firstname":"YevhenTest","lastname":"BoltDev", "extensionAttributes":{"checkoutFields":{}},"saveInAddressBook":null} @param bool $needJsonEncode @return string
[ "Return", "billing", "address", "information", "formatted", "to", "be", "used", "for", "magento", "order", "creation", "." ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Block/Form.php#L81-L111
train
BoltApp/bolt-magento2
Plugin/RequireJs.php
RequireJs.afterGetFiles
public function afterGetFiles(RequireJsCollector $subject, array $files) { $magentoVersion = $this->productMetadata->getVersion(); if (version_compare($magentoVersion, '2.2.0', '>=')) { foreach ($files as $index => $file) { if ($file->getModule() === 'Bolt_Boltpay') { unset($files[$index]); } } } return $files; }
php
public function afterGetFiles(RequireJsCollector $subject, array $files) { $magentoVersion = $this->productMetadata->getVersion(); if (version_compare($magentoVersion, '2.2.0', '>=')) { foreach ($files as $index => $file) { if ($file->getModule() === 'Bolt_Boltpay') { unset($files[$index]); } } } return $files; }
[ "public", "function", "afterGetFiles", "(", "RequireJsCollector", "$", "subject", ",", "array", "$", "files", ")", "{", "$", "magentoVersion", "=", "$", "this", "->", "productMetadata", "->", "getVersion", "(", ")", ";", "if", "(", "version_compare", "(", "$...
After requireJs files are collected remove the ones added by Bolt for the store version greater than or equal to 2.2.0. @param RequireJsCollector $subject @param array $files @return array
[ "After", "requireJs", "files", "are", "collected", "remove", "the", "ones", "added", "by", "Bolt", "for", "the", "store", "version", "greater", "than", "or", "equal", "to", "2", ".", "2", ".", "0", "." ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Plugin/RequireJs.php#L55-L69
train
BoltApp/bolt-magento2
Model/Api/ShippingMethods.php
ShippingMethods.validateEmail
private function validateEmail($email) { if (!$this->cartHelper->validateEmail($email)) { throw new BoltException( __('Invalid email: %1', $email), null, BoltErrorResponse::ERR_UNIQUE_EMAIL_REQUIRED ); } }
php
private function validateEmail($email) { if (!$this->cartHelper->validateEmail($email)) { throw new BoltException( __('Invalid email: %1', $email), null, BoltErrorResponse::ERR_UNIQUE_EMAIL_REQUIRED ); } }
[ "private", "function", "validateEmail", "(", "$", "email", ")", "{", "if", "(", "!", "$", "this", "->", "cartHelper", "->", "validateEmail", "(", "$", "email", ")", ")", "{", "throw", "new", "BoltException", "(", "__", "(", "'Invalid email: %1'", ",", "$...
Validate request email @param $email @throws BoltException @throws \Zend_Validate_Exception
[ "Validate", "request", "email" ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Model/Api/ShippingMethods.php#L289-L298
train
BoltApp/bolt-magento2
Model/Api/ShippingMethods.php
ShippingMethods.getShippingMethods
public function getShippingMethods($cart, $shipping_address) { try { // $this->logHelper->addInfoLog($this->request->getContent()); $this->preprocessHook(); // get immutable quote id stored with transaction list(, $quoteId) = explode(' / ', $cart['display_id']); // Load quote from entity id $quote = $this->cartHelper->getQuoteById($quoteId); if (!$quote || !$quote->getId()) { $this->throwUnknownQuoteIdException($quoteId); } $this->checkCartItems($cart, $quote); // Load logged in customer checkout and customer sessions from cached session id. // Replace parent quote with immutable quote in checkout session. $this->sessionHelper->loadSession($quote); $addressData = $this->cartHelper->handleSpecialAddressCases($shipping_address); if (isset($addressData['email']) && $addressData['email'] !== null) { $this->validateAddressData($addressData); } $shippingOptionsModel = $this->shippingEstimation($quote, $addressData); if ($this->taxAdjusted) { $this->bugsnag->registerCallback(function ($report) use ($shippingOptionsModel) { $report->setMetaData([ 'SHIPPING OPTIONS' => [print_r($shippingOptionsModel, 1)] ]); }); $this->bugsnag->notifyError('Cart Totals Mismatch', "Totals adjusted."); } /** @var \Magento\Quote\Model\Quote $parentQuote */ $parentQuote = $this->cartHelper->getQuoteById($cart['order_reference']); if ($this->couponInvalidForShippingAddress($parentQuote->getCouponCode(), $quote)){ $address = $parentQuote->isVirtual() ? $parentQuote->getBillingAddress() : $parentQuote->getShippingAddress(); $additionalAmount = abs($this->cartHelper->getRoundAmount($address->getDiscountAmount())); $shippingOptionsModel->addAmountToShippingOptions($additionalAmount); } return $shippingOptionsModel; } catch (\Magento\Framework\Webapi\Exception $e) { $this->catchExceptionAndSendError($e, $e->getMessage(), $e->getCode(), $e->getHttpCode()); } catch (BoltException $e) { $this->catchExceptionAndSendError($e, $e->getMessage(), $e->getCode()); } catch (\Exception $e) { $msg = __('Unprocessable Entity') . ': ' . $e->getMessage(); $this->catchExceptionAndSendError($e, $msg, 6009, 422); } }
php
public function getShippingMethods($cart, $shipping_address) { try { // $this->logHelper->addInfoLog($this->request->getContent()); $this->preprocessHook(); // get immutable quote id stored with transaction list(, $quoteId) = explode(' / ', $cart['display_id']); // Load quote from entity id $quote = $this->cartHelper->getQuoteById($quoteId); if (!$quote || !$quote->getId()) { $this->throwUnknownQuoteIdException($quoteId); } $this->checkCartItems($cart, $quote); // Load logged in customer checkout and customer sessions from cached session id. // Replace parent quote with immutable quote in checkout session. $this->sessionHelper->loadSession($quote); $addressData = $this->cartHelper->handleSpecialAddressCases($shipping_address); if (isset($addressData['email']) && $addressData['email'] !== null) { $this->validateAddressData($addressData); } $shippingOptionsModel = $this->shippingEstimation($quote, $addressData); if ($this->taxAdjusted) { $this->bugsnag->registerCallback(function ($report) use ($shippingOptionsModel) { $report->setMetaData([ 'SHIPPING OPTIONS' => [print_r($shippingOptionsModel, 1)] ]); }); $this->bugsnag->notifyError('Cart Totals Mismatch', "Totals adjusted."); } /** @var \Magento\Quote\Model\Quote $parentQuote */ $parentQuote = $this->cartHelper->getQuoteById($cart['order_reference']); if ($this->couponInvalidForShippingAddress($parentQuote->getCouponCode(), $quote)){ $address = $parentQuote->isVirtual() ? $parentQuote->getBillingAddress() : $parentQuote->getShippingAddress(); $additionalAmount = abs($this->cartHelper->getRoundAmount($address->getDiscountAmount())); $shippingOptionsModel->addAmountToShippingOptions($additionalAmount); } return $shippingOptionsModel; } catch (\Magento\Framework\Webapi\Exception $e) { $this->catchExceptionAndSendError($e, $e->getMessage(), $e->getCode(), $e->getHttpCode()); } catch (BoltException $e) { $this->catchExceptionAndSendError($e, $e->getMessage(), $e->getCode()); } catch (\Exception $e) { $msg = __('Unprocessable Entity') . ': ' . $e->getMessage(); $this->catchExceptionAndSendError($e, $msg, 6009, 422); } }
[ "public", "function", "getShippingMethods", "(", "$", "cart", ",", "$", "shipping_address", ")", "{", "try", "{", "// $this->logHelper->addInfoLog($this->request->getContent());", "$", "this", "->", "preprocessHook", "(", ")", ";", "// get immutable quote id stor...
Get all available shipping methods and tax data. @api @param array $cart cart details @param array $shipping_address shipping address @return ShippingOptionsInterface @throws \Exception
[ "Get", "all", "available", "shipping", "methods", "and", "tax", "data", "." ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Model/Api/ShippingMethods.php#L311-L369
train
BoltApp/bolt-magento2
Model/Api/ShippingMethods.php
ShippingMethods.getShippingOptionsData
protected function getShippingOptionsData($shippingMethods) { $shippingOptionsModel = $this->shippingOptionsInterfaceFactory->create(); $shippingTaxModel = $this->shippingTaxInterfaceFactory->create(); $shippingTaxModel->setAmount(0); $shippingOptionsModel->setShippingOptions($shippingMethods); $shippingOptionsModel->setTaxResult($shippingTaxModel); return $shippingOptionsModel; }
php
protected function getShippingOptionsData($shippingMethods) { $shippingOptionsModel = $this->shippingOptionsInterfaceFactory->create(); $shippingTaxModel = $this->shippingTaxInterfaceFactory->create(); $shippingTaxModel->setAmount(0); $shippingOptionsModel->setShippingOptions($shippingMethods); $shippingOptionsModel->setTaxResult($shippingTaxModel); return $shippingOptionsModel; }
[ "protected", "function", "getShippingOptionsData", "(", "$", "shippingMethods", ")", "{", "$", "shippingOptionsModel", "=", "$", "this", "->", "shippingOptionsInterfaceFactory", "->", "create", "(", ")", ";", "$", "shippingTaxModel", "=", "$", "this", "->", "shipp...
Set shipping methods to the ShippingOptions object @param $shippingMethods
[ "Set", "shipping", "methods", "to", "the", "ShippingOptions", "object" ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Model/Api/ShippingMethods.php#L536-L547
train
BoltApp/bolt-magento2
Model/Api/ShippingMethods.php
ShippingMethods.resetShippingCalculationIfNeeded
private function resetShippingCalculationIfNeeded($shippingAddress) { if ($this->configHelper->getResetShippingCalculation()) { $shippingAddress->removeAllShippingRates(); $shippingAddress->setCollectShippingRates(true); } }
php
private function resetShippingCalculationIfNeeded($shippingAddress) { if ($this->configHelper->getResetShippingCalculation()) { $shippingAddress->removeAllShippingRates(); $shippingAddress->setCollectShippingRates(true); } }
[ "private", "function", "resetShippingCalculationIfNeeded", "(", "$", "shippingAddress", ")", "{", "if", "(", "$", "this", "->", "configHelper", "->", "getResetShippingCalculation", "(", ")", ")", "{", "$", "shippingAddress", "->", "removeAllShippingRates", "(", ")",...
Reset shipping calculation On some store setups shipping prices are conditionally changed depending on some custom logic. If it is done as a plugin for some method in the Magento shipping flow, then that method may be (indirectly) called from our Shipping And Tax flow more than once, resulting in wrong prices. This function resets address shipping calculation but can seriously slow down the process (on a system with many shipping options available). Use it carefully only when necesarry. @param \Magento\Quote\Model\Quote\Address $shippingAddress
[ "Reset", "shipping", "calculation" ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Model/Api/ShippingMethods.php#L563-L569
train
BoltApp/bolt-magento2
Model/Payment.php
Payment.void
public function void(InfoInterface $payment) { try { $transactionId = $payment->getAdditionalInformation('real_transaction_id'); if (empty($transactionId)) { throw new LocalizedException( __('Please wait while transaction gets updated from Bolt.') ); } //Get transaction data $transactionData = ['transaction_id' => $transactionId]; $apiKey = $this->configHelper->getApiKey(); //Request Data $requestData = $this->dataObjectFactory->create(); $requestData->setApiData($transactionData); $requestData->setDynamicApiUrl(ApiHelper::API_VOID_TRANSACTION); $requestData->setApiKey($apiKey); //Build Request $request = $this->apiHelper->buildRequest($requestData); $result = $this->apiHelper->sendRequest($request); $response = $result->getResponse(); if (empty($response)) { throw new LocalizedException( __('Bad void response from boltpay') ); } if (@$response->status != 'cancelled') { throw new LocalizedException(__('Payment void error.')); } $order = $payment->getOrder(); $this->orderHelper->updateOrderPayment($order, null, $response->reference); return $this; } catch (\Exception $e) { $this->bugsnag->notifyException($e); throw $e; } }
php
public function void(InfoInterface $payment) { try { $transactionId = $payment->getAdditionalInformation('real_transaction_id'); if (empty($transactionId)) { throw new LocalizedException( __('Please wait while transaction gets updated from Bolt.') ); } //Get transaction data $transactionData = ['transaction_id' => $transactionId]; $apiKey = $this->configHelper->getApiKey(); //Request Data $requestData = $this->dataObjectFactory->create(); $requestData->setApiData($transactionData); $requestData->setDynamicApiUrl(ApiHelper::API_VOID_TRANSACTION); $requestData->setApiKey($apiKey); //Build Request $request = $this->apiHelper->buildRequest($requestData); $result = $this->apiHelper->sendRequest($request); $response = $result->getResponse(); if (empty($response)) { throw new LocalizedException( __('Bad void response from boltpay') ); } if (@$response->status != 'cancelled') { throw new LocalizedException(__('Payment void error.')); } $order = $payment->getOrder(); $this->orderHelper->updateOrderPayment($order, null, $response->reference); return $this; } catch (\Exception $e) { $this->bugsnag->notifyException($e); throw $e; } }
[ "public", "function", "void", "(", "InfoInterface", "$", "payment", ")", "{", "try", "{", "$", "transactionId", "=", "$", "payment", "->", "getAdditionalInformation", "(", "'real_transaction_id'", ")", ";", "if", "(", "empty", "(", "$", "transactionId", ")", ...
Void the payment through gateway @param DataObject|InfoInterface $payment @return $this @throws \Exception
[ "Void", "the", "payment", "through", "gateway" ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Model/Payment.php#L240-L284
train
BoltApp/bolt-magento2
Model/Payment.php
Payment.capture
public function capture(InfoInterface $payment, $amount) { try { $order = $payment->getOrder(); if ($amount <= 0) { throw new LocalizedException(__('Invalid amount for capture.')); } $realTransactionId = $payment->getAdditionalInformation('real_transaction_id'); if (empty($realTransactionId)) { throw new LocalizedException( __('Please wait while transaction get updated from Bolt.') ); } $captureAmount = $amount * 100; //Get capture data $capturedData = [ 'transaction_id' => $realTransactionId, 'amount' => $captureAmount, 'currency' => $order->getOrderCurrencyCode() ]; $apiKey = $this->configHelper->getApiKey(); //Request Data $requestData = $this->dataObjectFactory->create(); $requestData->setApiData($capturedData); $requestData->setDynamicApiUrl(ApiHelper::API_CAPTURE_TRANSACTION); $requestData->setApiKey($apiKey); //Build Request $request = $this->apiHelper->buildRequest($requestData); $result = $this->apiHelper->sendRequest($request); $response = $result->getResponse(); if (empty($response)) { throw new LocalizedException( __('Bad capture response from boltpay') ); } if (!in_array(@$response->status, [self::TRANSACTION_AUTHORIZED, self::TRANSACTION_COMPLETED])) { throw new LocalizedException(__('Payment capture error.')); } $this->orderHelper->updateOrderPayment($order, null, $response->reference); return $this; } catch (\Exception $e) { $this->bugsnag->notifyException($e); throw $e; } }
php
public function capture(InfoInterface $payment, $amount) { try { $order = $payment->getOrder(); if ($amount <= 0) { throw new LocalizedException(__('Invalid amount for capture.')); } $realTransactionId = $payment->getAdditionalInformation('real_transaction_id'); if (empty($realTransactionId)) { throw new LocalizedException( __('Please wait while transaction get updated from Bolt.') ); } $captureAmount = $amount * 100; //Get capture data $capturedData = [ 'transaction_id' => $realTransactionId, 'amount' => $captureAmount, 'currency' => $order->getOrderCurrencyCode() ]; $apiKey = $this->configHelper->getApiKey(); //Request Data $requestData = $this->dataObjectFactory->create(); $requestData->setApiData($capturedData); $requestData->setDynamicApiUrl(ApiHelper::API_CAPTURE_TRANSACTION); $requestData->setApiKey($apiKey); //Build Request $request = $this->apiHelper->buildRequest($requestData); $result = $this->apiHelper->sendRequest($request); $response = $result->getResponse(); if (empty($response)) { throw new LocalizedException( __('Bad capture response from boltpay') ); } if (!in_array(@$response->status, [self::TRANSACTION_AUTHORIZED, self::TRANSACTION_COMPLETED])) { throw new LocalizedException(__('Payment capture error.')); } $this->orderHelper->updateOrderPayment($order, null, $response->reference); return $this; } catch (\Exception $e) { $this->bugsnag->notifyException($e); throw $e; } }
[ "public", "function", "capture", "(", "InfoInterface", "$", "payment", ",", "$", "amount", ")", "{", "try", "{", "$", "order", "=", "$", "payment", "->", "getOrder", "(", ")", ";", "if", "(", "$", "amount", "<=", "0", ")", "{", "throw", "new", "Loc...
Capture the authorized transaction through the gateway @param InfoInterface $payment @param float $amount @return $this @throws \Exception
[ "Capture", "the", "authorized", "transaction", "through", "the", "gateway" ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Model/Payment.php#L331-L387
train
BoltApp/bolt-magento2
Model/Payment.php
Payment.isAvailable
public function isAvailable(\Magento\Quote\Api\Data\CartInterface $quote = null) { // check for product restrictions if ($this->cartHelper->hasProductRestrictions($quote)) { return false; } return parent::isAvailable(); }
php
public function isAvailable(\Magento\Quote\Api\Data\CartInterface $quote = null) { // check for product restrictions if ($this->cartHelper->hasProductRestrictions($quote)) { return false; } return parent::isAvailable(); }
[ "public", "function", "isAvailable", "(", "\\", "Magento", "\\", "Quote", "\\", "Api", "\\", "Data", "\\", "CartInterface", "$", "quote", "=", "null", ")", "{", "// check for product restrictions", "if", "(", "$", "this", "->", "cartHelper", "->", "hasProductR...
Check whether payment method can be used @param \Magento\Quote\Api\Data\CartInterface|null $quote @return bool
[ "Check", "whether", "payment", "method", "can", "be", "used" ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Model/Payment.php#L472-L479
train
BoltApp/bolt-magento2
Helper/Cart.php
Cart.isCheckoutAllowed
public function isCheckoutAllowed() { return $this->customerSession->isLoggedIn() || $this->checkoutHelper->isAllowedGuestCheckout($this->checkoutSession->getQuote()); }
php
public function isCheckoutAllowed() { return $this->customerSession->isLoggedIn() || $this->checkoutHelper->isAllowedGuestCheckout($this->checkoutSession->getQuote()); }
[ "public", "function", "isCheckoutAllowed", "(", ")", "{", "return", "$", "this", "->", "customerSession", "->", "isLoggedIn", "(", ")", "||", "$", "this", "->", "checkoutHelper", "->", "isAllowedGuestCheckout", "(", "$", "this", "->", "checkoutSession", "->", ...
Check if guest checkout is allowed @return bool
[ "Check", "if", "guest", "checkout", "is", "allowed" ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Cart.php#L249-L252
train
BoltApp/bolt-magento2
Helper/Cart.php
Cart.getOrderByIncrementId
public function getOrderByIncrementId($incrementId) { $searchCriteria = $this->searchCriteriaBuilder ->addFilter('increment_id', $incrementId, 'eq')->create(); $collection = $this->orderRepository->getList($searchCriteria)->getItems(); return reset($collection); }
php
public function getOrderByIncrementId($incrementId) { $searchCriteria = $this->searchCriteriaBuilder ->addFilter('increment_id', $incrementId, 'eq')->create(); $collection = $this->orderRepository->getList($searchCriteria)->getItems(); return reset($collection); }
[ "public", "function", "getOrderByIncrementId", "(", "$", "incrementId", ")", "{", "$", "searchCriteria", "=", "$", "this", "->", "searchCriteriaBuilder", "->", "addFilter", "(", "'increment_id'", ",", "$", "incrementId", ",", "'eq'", ")", "->", "create", "(", ...
Load Order by increment id @param $incrementId @return \Magento\Sales\Api\Data\OrderInterface|mixed
[ "Load", "Order", "by", "increment", "id" ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Cart.php#L281-L287
train
BoltApp/bolt-magento2
Helper/Cart.php
Cart.getBoltpayOrder
public function getBoltpayOrder($paymentOnly, $placeOrderPayload, $storeId = 0) { //Get cart data $cart = $this->getCartData($paymentOnly, $placeOrderPayload); if (!$cart) { return; } // cache the session id $this->sessionHelper->saveSession($cart['order_reference'], $this->checkoutSession); // If storeId was missed through request, then try to get it from the session quote. if (!$storeId && $this->checkoutSession->getQuote()) { $storeId = $this->checkoutSession->getQuote()->getStoreId(); } $apiKey = $this->configHelper->getApiKey($storeId); //Request Data $requestData = $this->dataObjectFactory->create(); $requestData->setApiData(['cart' => $cart]); $requestData->setDynamicApiUrl(ApiHelper::API_CREATE_ORDER); $requestData->setApiKey($apiKey); //Build Request $request = $this->apiHelper->buildRequest($requestData); $result = $this->apiHelper->sendRequest($request); return $result; }
php
public function getBoltpayOrder($paymentOnly, $placeOrderPayload, $storeId = 0) { //Get cart data $cart = $this->getCartData($paymentOnly, $placeOrderPayload); if (!$cart) { return; } // cache the session id $this->sessionHelper->saveSession($cart['order_reference'], $this->checkoutSession); // If storeId was missed through request, then try to get it from the session quote. if (!$storeId && $this->checkoutSession->getQuote()) { $storeId = $this->checkoutSession->getQuote()->getStoreId(); } $apiKey = $this->configHelper->getApiKey($storeId); //Request Data $requestData = $this->dataObjectFactory->create(); $requestData->setApiData(['cart' => $cart]); $requestData->setDynamicApiUrl(ApiHelper::API_CREATE_ORDER); $requestData->setApiKey($apiKey); //Build Request $request = $this->apiHelper->buildRequest($requestData); $result = $this->apiHelper->sendRequest($request); return $result; }
[ "public", "function", "getBoltpayOrder", "(", "$", "paymentOnly", ",", "$", "placeOrderPayload", ",", "$", "storeId", "=", "0", ")", "{", "//Get cart data", "$", "cart", "=", "$", "this", "->", "getCartData", "(", "$", "paymentOnly", ",", "$", "placeOrderPay...
Create order on bolt @param bool $paymentOnly flag that represents the type of checkout @param string $placeOrderPayload additional data collected from the (one page checkout) page, i.e. billing address to be saved with the order @param int $storeId @return Response|void @throws LocalizedException @throws Zend_Http_Client_Exception
[ "Create", "order", "on", "bolt" ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Cart.php#L323-L351
train
BoltApp/bolt-magento2
Helper/Cart.php
Cart.getSignResponse
private function getSignResponse($signRequest) { $apiKey = $this->configHelper->getApiKey(); //Request Data $requestData = $this->dataObjectFactory->create(); $requestData->setApiData($signRequest); $requestData->setDynamicApiUrl(ApiHelper::API_SIGN); $requestData->setApiKey($apiKey); $request = $this->apiHelper->buildRequest($requestData); try { $result = $this->apiHelper->sendRequest($request); } catch (\Exception $e) { return null; } return $result; }
php
private function getSignResponse($signRequest) { $apiKey = $this->configHelper->getApiKey(); //Request Data $requestData = $this->dataObjectFactory->create(); $requestData->setApiData($signRequest); $requestData->setDynamicApiUrl(ApiHelper::API_SIGN); $requestData->setApiKey($apiKey); $request = $this->apiHelper->buildRequest($requestData); try { $result = $this->apiHelper->sendRequest($request); } catch (\Exception $e) { return null; } return $result; }
[ "private", "function", "getSignResponse", "(", "$", "signRequest", ")", "{", "$", "apiKey", "=", "$", "this", "->", "configHelper", "->", "getApiKey", "(", ")", ";", "//Request Data", "$", "requestData", "=", "$", "this", "->", "dataObjectFactory", "->", "cr...
Sign a payload using the Bolt endpoint @param array $signRequest payload to sign @return Response|int
[ "Sign", "a", "payload", "using", "the", "Bolt", "endpoint" ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Cart.php#L360-L377
train
BoltApp/bolt-magento2
Helper/Cart.php
Cart.getHints
public function getHints($cartReference = null, $checkoutType = 'admin') { /** @var Quote */ $quote = $cartReference ? $this->getQuoteById($cartReference) : $this->checkoutSession->getQuote(); $hints = ['prefill' => []]; /** * Update hints from address data * * @param Address $address */ $prefillHints = function ($address) use (&$hints, $quote) { if (!$address) { return; } $prefill = [ 'firstName' => $address->getFirstname(), 'lastName' => $address->getLastname(), 'email' => $address->getEmail() ?: $quote->getCustomerEmail(), 'phone' => $address->getTelephone(), 'addressLine1' => $address->getStreetLine(1), 'addressLine2' => $address->getStreetLine(2), 'city' => $address->getCity(), 'state' => $address->getRegion(), 'zip' => $address->getPostcode(), 'country' => $address->getCountryId(), ]; foreach ($prefill as $name => $value) { if (empty($value)) { unset($prefill[$name]); } } $hints['prefill'] = array_merge($hints['prefill'], $prefill); }; // Logged in customes. // Merchant scope and prefill. if ($this->customerSession->isLoggedIn()) { $customer = $this->customerSession->getCustomer(); $signRequest = [ 'merchant_user_id' => $customer->getId(), ]; $signResponse = $this->getSignResponse($signRequest)->getResponse(); if ($signResponse) { $hints['merchant_user_id'] = $signResponse->merchant_user_id; $hints['signature'] = $signResponse->signature; $hints['nonce'] = $signResponse->nonce; } if ($quote->isVirtual()) { $prefillHints($customer->getDefaultBillingAddress()); } else { $prefillHints($customer->getDefaultShippingAddress()); } $hints['prefill']['email'] = $customer->getEmail(); } // Quote shipping / billing address. // If assigned it takes precedence over logged in user default address. if ($quote->isVirtual()) { $prefillHints($quote->getBillingAddress()); } else { $prefillHints($quote->getShippingAddress()); } if ($checkoutType === 'admin') { $hints['virtual_terminal_mode'] = true; } return $hints; }
php
public function getHints($cartReference = null, $checkoutType = 'admin') { /** @var Quote */ $quote = $cartReference ? $this->getQuoteById($cartReference) : $this->checkoutSession->getQuote(); $hints = ['prefill' => []]; /** * Update hints from address data * * @param Address $address */ $prefillHints = function ($address) use (&$hints, $quote) { if (!$address) { return; } $prefill = [ 'firstName' => $address->getFirstname(), 'lastName' => $address->getLastname(), 'email' => $address->getEmail() ?: $quote->getCustomerEmail(), 'phone' => $address->getTelephone(), 'addressLine1' => $address->getStreetLine(1), 'addressLine2' => $address->getStreetLine(2), 'city' => $address->getCity(), 'state' => $address->getRegion(), 'zip' => $address->getPostcode(), 'country' => $address->getCountryId(), ]; foreach ($prefill as $name => $value) { if (empty($value)) { unset($prefill[$name]); } } $hints['prefill'] = array_merge($hints['prefill'], $prefill); }; // Logged in customes. // Merchant scope and prefill. if ($this->customerSession->isLoggedIn()) { $customer = $this->customerSession->getCustomer(); $signRequest = [ 'merchant_user_id' => $customer->getId(), ]; $signResponse = $this->getSignResponse($signRequest)->getResponse(); if ($signResponse) { $hints['merchant_user_id'] = $signResponse->merchant_user_id; $hints['signature'] = $signResponse->signature; $hints['nonce'] = $signResponse->nonce; } if ($quote->isVirtual()) { $prefillHints($customer->getDefaultBillingAddress()); } else { $prefillHints($customer->getDefaultShippingAddress()); } $hints['prefill']['email'] = $customer->getEmail(); } // Quote shipping / billing address. // If assigned it takes precedence over logged in user default address. if ($quote->isVirtual()) { $prefillHints($quote->getBillingAddress()); } else { $prefillHints($quote->getShippingAddress()); } if ($checkoutType === 'admin') { $hints['virtual_terminal_mode'] = true; } return $hints; }
[ "public", "function", "getHints", "(", "$", "cartReference", "=", "null", ",", "$", "checkoutType", "=", "'admin'", ")", "{", "/** @var Quote */", "$", "quote", "=", "$", "cartReference", "?", "$", "this", "->", "getQuoteById", "(", "$", "cartReference", ")"...
Get the hints data for checkout @param string $cartReference (immutable) quote id @param string $checkoutType 'cart' | 'admin' Default to `admin` @return array @throws NoSuchEntityException
[ "Get", "the", "hints", "data", "for", "checkout" ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Cart.php#L388-L468
train
BoltApp/bolt-magento2
Helper/Cart.php
Cart.transferData
private function transferData( $parent, $child, $save = true, $emailFields = ['customer_email', 'email'], $excludeFields = ['entity_id', 'address_id', 'reserved_order_id'] ) { foreach ($parent->getData() as $key => $value) { if (in_array($key, $excludeFields)) continue; if (in_array($key, $emailFields) && !$this->validateEmail($value)) continue; $child->setData($key, $value); } if ($save) $child->save(); }
php
private function transferData( $parent, $child, $save = true, $emailFields = ['customer_email', 'email'], $excludeFields = ['entity_id', 'address_id', 'reserved_order_id'] ) { foreach ($parent->getData() as $key => $value) { if (in_array($key, $excludeFields)) continue; if (in_array($key, $emailFields) && !$this->validateEmail($value)) continue; $child->setData($key, $value); } if ($save) $child->save(); }
[ "private", "function", "transferData", "(", "$", "parent", ",", "$", "child", ",", "$", "save", "=", "true", ",", "$", "emailFields", "=", "[", "'customer_email'", ",", "'email'", "]", ",", "$", "excludeFields", "=", "[", "'entity_id'", ",", "'address_id'"...
Set immutable quote and addresses data from the parent quote @param Quote|QuoteAddress $parent parent object @param Quote|QuoteAddress $child child object @param bool $save if set to true save the $child instance upon the transfer @param array $emailFields fields that need to pass email validation to be transfered, skipped otherwise @param array $excludeFields fields to be excluded from the transfer (e.g. unique identifiers) @throws \Zend_Validate_Exception
[ "Set", "immutable", "quote", "and", "addresses", "data", "from", "the", "parent", "quote" ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Cart.php#L480-L495
train
BoltApp/bolt-magento2
Helper/Cart.php
Cart.replicateQuoteData
public function replicateQuoteData($source, $destination) { // Skip the replication if source and destination point to the same quote // E.g. delayed Save Order - immutable quote is cleared by cron and we use the parent instead if ($source->getId() == $destination->getId()) return; $destinationId = $destination->getId(); $destinationActive = (bool)$destination->getIsActive(); $destination->removeAllItems(); $destination->merge($source); $destination->getBillingAddress()->setShouldIgnoreValidation(true); $this->transferData($source->getBillingAddress(), $destination->getBillingAddress()); $destination->getShippingAddress()->setShouldIgnoreValidation(true); $this->transferData($source->getShippingAddress(), $destination->getShippingAddress()); $this->transferData($source, $destination, false); $destination->setId($destinationId); $destination->setIsActive($destinationActive); $this->quoteResourceSave($destination); // If Amasty Gif Cart Extension is present clone applied gift cards $this->discountHelper->cloneAmastyGiftCards($source->getId(), $destination->getId()); }
php
public function replicateQuoteData($source, $destination) { // Skip the replication if source and destination point to the same quote // E.g. delayed Save Order - immutable quote is cleared by cron and we use the parent instead if ($source->getId() == $destination->getId()) return; $destinationId = $destination->getId(); $destinationActive = (bool)$destination->getIsActive(); $destination->removeAllItems(); $destination->merge($source); $destination->getBillingAddress()->setShouldIgnoreValidation(true); $this->transferData($source->getBillingAddress(), $destination->getBillingAddress()); $destination->getShippingAddress()->setShouldIgnoreValidation(true); $this->transferData($source->getShippingAddress(), $destination->getShippingAddress()); $this->transferData($source, $destination, false); $destination->setId($destinationId); $destination->setIsActive($destinationActive); $this->quoteResourceSave($destination); // If Amasty Gif Cart Extension is present clone applied gift cards $this->discountHelper->cloneAmastyGiftCards($source->getId(), $destination->getId()); }
[ "public", "function", "replicateQuoteData", "(", "$", "source", ",", "$", "destination", ")", "{", "// Skip the replication if source and destination point to the same quote", "// E.g. delayed Save Order - immutable quote is cleared by cron and we use the parent instead", "if", "(", "$...
Clone quote data from source to destination @param Quote $source @param Quote $destination @throws \Magento\Framework\Exception\AlreadyExistsException @throws \Zend_Validate_Exception
[ "Clone", "quote", "data", "from", "source", "to", "destination" ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Cart.php#L505-L533
train
BoltApp/bolt-magento2
Helper/Cart.php
Cart.createImmutableQuote
protected function createImmutableQuote($quote) { if (!$quote->getBoltParentQuoteId()) { $quote->setBoltParentQuoteId($quote->getId()); $this->quoteResourceSave($quote); } /** @var Quote $immutableQuote */ $immutableQuote = $this->quoteFactory->create(); $this->replicateQuoteData($quote, $immutableQuote); return $immutableQuote; }
php
protected function createImmutableQuote($quote) { if (!$quote->getBoltParentQuoteId()) { $quote->setBoltParentQuoteId($quote->getId()); $this->quoteResourceSave($quote); } /** @var Quote $immutableQuote */ $immutableQuote = $this->quoteFactory->create(); $this->replicateQuoteData($quote, $immutableQuote); return $immutableQuote; }
[ "protected", "function", "createImmutableQuote", "(", "$", "quote", ")", "{", "if", "(", "!", "$", "quote", "->", "getBoltParentQuoteId", "(", ")", ")", "{", "$", "quote", "->", "setBoltParentQuoteId", "(", "$", "quote", "->", "getId", "(", ")", ")", ";"...
Create an immutable quote. Set the BoltParentQuoteId to the parent quote, if not set already, so it can be replicated to immutable quote in replicateQuoteData. @param Quote $quote @throws \Magento\Framework\Exception\AlreadyExistsException @throws \Zend_Validate_Exception
[ "Create", "an", "immutable", "quote", ".", "Set", "the", "BoltParentQuoteId", "to", "the", "parent", "quote", "if", "not", "set", "already", "so", "it", "can", "be", "replicated", "to", "immutable", "quote", "in", "replicateQuoteData", "." ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Cart.php#L571-L583
train
BoltApp/bolt-magento2
Helper/Cart.php
Cart.isAddressComplete
private function isAddressComplete($address) { foreach ($this->requiredAddressFields as $field) { if (empty($address[$field])) { return false; } } return true; }
php
private function isAddressComplete($address) { foreach ($this->requiredAddressFields as $field) { if (empty($address[$field])) { return false; } } return true; }
[ "private", "function", "isAddressComplete", "(", "$", "address", ")", "{", "foreach", "(", "$", "this", "->", "requiredAddressFields", "as", "$", "field", ")", "{", "if", "(", "empty", "(", "$", "address", "[", "$", "field", "]", ")", ")", "{", "return...
Check if all the required address fields are populated. @param array $address @return bool
[ "Check", "if", "all", "the", "required", "address", "fields", "are", "populated", "." ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Cart.php#L591-L599
train
BoltApp/bolt-magento2
Helper/Cart.php
Cart.logAddressData
private function logAddressData($addressData) { $this->bugsnag->registerCallback(function ($report) use ($addressData) { $report->setMetaData([ 'ADDRESS_DATA' => $addressData ]); }); }
php
private function logAddressData($addressData) { $this->bugsnag->registerCallback(function ($report) use ($addressData) { $report->setMetaData([ 'ADDRESS_DATA' => $addressData ]); }); }
[ "private", "function", "logAddressData", "(", "$", "addressData", ")", "{", "$", "this", "->", "bugsnag", "->", "registerCallback", "(", "function", "(", "$", "report", ")", "use", "(", "$", "addressData", ")", "{", "$", "report", "->", "setMetaData", "(",...
Bugsnag address data @param array $addressData
[ "Bugsnag", "address", "data" ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Cart.php#L606-L612
train
BoltApp/bolt-magento2
Helper/Cart.php
Cart.handlePuertoRico
private function handlePuertoRico($addressData) { $address = (array)$addressData; if ($address['country_code'] === 'PR') { $address['country_code'] = 'US'; $address['country'] = 'United States'; $address['region'] = 'Puerto Rico'; } return is_object($addressData) ? (object)$address : $address; }
php
private function handlePuertoRico($addressData) { $address = (array)$addressData; if ($address['country_code'] === 'PR') { $address['country_code'] = 'US'; $address['country'] = 'United States'; $address['region'] = 'Puerto Rico'; } return is_object($addressData) ? (object)$address : $address; }
[ "private", "function", "handlePuertoRico", "(", "$", "addressData", ")", "{", "$", "address", "=", "(", "array", ")", "$", "addressData", ";", "if", "(", "$", "address", "[", "'country_code'", "]", "===", "'PR'", ")", "{", "$", "address", "[", "'country_...
Handle Puerto Rico address special case. Bolt thinks Puerto Rico is a country magento thinks it is US. @param array|object $addressData @return array|object
[ "Handle", "Puerto", "Rico", "address", "special", "case", ".", "Bolt", "thinks", "Puerto", "Rico", "is", "a", "country", "magento", "thinks", "it", "is", "US", "." ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Cart.php#L1154-L1163
train
BoltApp/bolt-magento2
Helper/Cart.php
Cart.hasProductRestrictions
public function hasProductRestrictions($quote = null) { $toggleCheckout = $this->configHelper->getToggleCheckout(); if (!$toggleCheckout || !$toggleCheckout->active) { return false; } // get configured Product model getters that can restrict Bolt checkout usage $productRestrictionMethods = $toggleCheckout->productRestrictionMethods ?: []; // get configured Quote Item getters that can restrict Bolt checkout usage $itemRestrictionMethods = $toggleCheckout->itemRestrictionMethods ?: []; if (!$productRestrictionMethods && !$itemRestrictionMethods) { return false; } /** @var Quote $quote */ $quote = $quote ?: $this->checkoutSession->getQuote(); foreach ($quote->getAllVisibleItems() as $item) { // call every method on item, if returns true, do restrict foreach ($itemRestrictionMethods as $method) { if ($item->$method()) { return true; } } // Non empty check to avoid unnecessary model load if ($productRestrictionMethods) { // get item product $product = $this->productFactory->create()->load($item->getProductId()); // call every method on product, if returns true, do restrict foreach ($productRestrictionMethods as $method) { if ($product->$method()) { return true; } } } } // no restrictions return false; }
php
public function hasProductRestrictions($quote = null) { $toggleCheckout = $this->configHelper->getToggleCheckout(); if (!$toggleCheckout || !$toggleCheckout->active) { return false; } // get configured Product model getters that can restrict Bolt checkout usage $productRestrictionMethods = $toggleCheckout->productRestrictionMethods ?: []; // get configured Quote Item getters that can restrict Bolt checkout usage $itemRestrictionMethods = $toggleCheckout->itemRestrictionMethods ?: []; if (!$productRestrictionMethods && !$itemRestrictionMethods) { return false; } /** @var Quote $quote */ $quote = $quote ?: $this->checkoutSession->getQuote(); foreach ($quote->getAllVisibleItems() as $item) { // call every method on item, if returns true, do restrict foreach ($itemRestrictionMethods as $method) { if ($item->$method()) { return true; } } // Non empty check to avoid unnecessary model load if ($productRestrictionMethods) { // get item product $product = $this->productFactory->create()->load($item->getProductId()); // call every method on product, if returns true, do restrict foreach ($productRestrictionMethods as $method) { if ($product->$method()) { return true; } } } } // no restrictions return false; }
[ "public", "function", "hasProductRestrictions", "(", "$", "quote", "=", "null", ")", "{", "$", "toggleCheckout", "=", "$", "this", "->", "configHelper", "->", "getToggleCheckout", "(", ")", ";", "if", "(", "!", "$", "toggleCheckout", "||", "!", "$", "toggl...
Check the cart items for properties that are a restriction to Bolt checkout. Properties are checked with getters specified in configuration. @param Quote|null $quote @return bool
[ "Check", "the", "cart", "items", "for", "properties", "that", "are", "a", "restriction", "to", "Bolt", "checkout", ".", "Properties", "are", "checked", "with", "getters", "specified", "in", "configuration", "." ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Cart.php#L1172-L1215
train
BoltApp/bolt-magento2
Controller/Order/Save.php
Save.clearQuoteSession
private function clearQuoteSession($quote) { $this->checkoutSession->setLastQuoteId($quote->getId()) ->setLastSuccessQuoteId($quote->getId()) ->clearHelperData(); }
php
private function clearQuoteSession($quote) { $this->checkoutSession->setLastQuoteId($quote->getId()) ->setLastSuccessQuoteId($quote->getId()) ->clearHelperData(); }
[ "private", "function", "clearQuoteSession", "(", "$", "quote", ")", "{", "$", "this", "->", "checkoutSession", "->", "setLastQuoteId", "(", "$", "quote", "->", "getId", "(", ")", ")", "->", "setLastSuccessQuoteId", "(", "$", "quote", "->", "getId", "(", ")...
Clear quote session after successful order @param Quote $quote @return void
[ "Clear", "quote", "session", "after", "successful", "order" ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Controller/Order/Save.php#L154-L159
train
BoltApp/bolt-magento2
Controller/Order/Save.php
Save.clearOrderSession
private function clearOrderSession($order) { $this->checkoutSession->setLastOrderId($order->getId()) ->setLastRealOrderId($order->getIncrementId()) ->setLastOrderStatus($order->getStatus()); }
php
private function clearOrderSession($order) { $this->checkoutSession->setLastOrderId($order->getId()) ->setLastRealOrderId($order->getIncrementId()) ->setLastOrderStatus($order->getStatus()); }
[ "private", "function", "clearOrderSession", "(", "$", "order", ")", "{", "$", "this", "->", "checkoutSession", "->", "setLastOrderId", "(", "$", "order", "->", "getId", "(", ")", ")", "->", "setLastRealOrderId", "(", "$", "order", "->", "getIncrementId", "("...
Clear order session after successful order @param Order $order @return void
[ "Clear", "order", "session", "after", "successful", "order" ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Controller/Order/Save.php#L168-L173
train
BoltApp/bolt-magento2
Helper/Api.php
Api.getFullApiUrl
private function getFullApiUrl($dynamicUrl) { $staticUrl = $this->configHelper->getApiUrl(); return $staticUrl . self::API_CURRENT_VERSION . $dynamicUrl; }
php
private function getFullApiUrl($dynamicUrl) { $staticUrl = $this->configHelper->getApiUrl(); return $staticUrl . self::API_CURRENT_VERSION . $dynamicUrl; }
[ "private", "function", "getFullApiUrl", "(", "$", "dynamicUrl", ")", "{", "$", "staticUrl", "=", "$", "this", "->", "configHelper", "->", "getApiUrl", "(", ")", ";", "return", "$", "staticUrl", ".", "self", "::", "API_CURRENT_VERSION", ".", "$", "dynamicUrl"...
Get Full API Endpoint @param string $dynamicUrl @return string
[ "Get", "Full", "API", "Endpoint" ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Api.php#L157-L161
train
BoltApp/bolt-magento2
Helper/Order.php
Order.setShippingMethod
private function setShippingMethod($quote, $transaction) { if ($quote->isVirtual()) { return; } $shippingAddress = $quote->getShippingAddress(); $shippingAddress->setCollectShippingRates(true); $shippingMethod = $transaction->order->cart->shipments[0]->reference; $shippingAddress->setShippingMethod($shippingMethod)->save(); }
php
private function setShippingMethod($quote, $transaction) { if ($quote->isVirtual()) { return; } $shippingAddress = $quote->getShippingAddress(); $shippingAddress->setCollectShippingRates(true); $shippingMethod = $transaction->order->cart->shipments[0]->reference; $shippingAddress->setShippingMethod($shippingMethod)->save(); }
[ "private", "function", "setShippingMethod", "(", "$", "quote", ",", "$", "transaction", ")", "{", "if", "(", "$", "quote", "->", "isVirtual", "(", ")", ")", "{", "return", ";", "}", "$", "shippingAddress", "=", "$", "quote", "->", "getShippingAddress", "...
Set quote shipping method from transaction data @param Quote $quote @param $transaction @throws \Exception
[ "Set", "quote", "shipping", "method", "from", "transaction", "data" ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Order.php#L310-L322
train
BoltApp/bolt-magento2
Helper/Order.php
Order.setAddress
private function setAddress($quoteAddress, $address) { $address = $this->cartHelper->handleSpecialAddressCases($address); $region = $this->regionModel->loadByName(@$address->region, @$address->country_code); $addressData = [ 'firstname' => @$address->first_name, 'lastname' => @$address->last_name, 'street' => trim(@$address->street_address1 . "\n" . @$address->street_address2), 'city' => @$address->locality, 'country_id' => @$address->country_code, 'region' => @$address->region, 'postcode' => @$address->postal_code, 'telephone' => @$address->phone_number, 'region_id' => $region ? $region->getId() : null, 'company' => @$address->company, ]; if ($this->cartHelper->validateEmail(@$address->email_address)) { $addressData['email'] = $address->email_address; } // discard empty address fields foreach ($addressData as $key => $value) { if (empty($value)) { unset($addressData[$key]); } } $quoteAddress->setShouldIgnoreValidation(true); $quoteAddress->addData($addressData)->save(); }
php
private function setAddress($quoteAddress, $address) { $address = $this->cartHelper->handleSpecialAddressCases($address); $region = $this->regionModel->loadByName(@$address->region, @$address->country_code); $addressData = [ 'firstname' => @$address->first_name, 'lastname' => @$address->last_name, 'street' => trim(@$address->street_address1 . "\n" . @$address->street_address2), 'city' => @$address->locality, 'country_id' => @$address->country_code, 'region' => @$address->region, 'postcode' => @$address->postal_code, 'telephone' => @$address->phone_number, 'region_id' => $region ? $region->getId() : null, 'company' => @$address->company, ]; if ($this->cartHelper->validateEmail(@$address->email_address)) { $addressData['email'] = $address->email_address; } // discard empty address fields foreach ($addressData as $key => $value) { if (empty($value)) { unset($addressData[$key]); } } $quoteAddress->setShouldIgnoreValidation(true); $quoteAddress->addData($addressData)->save(); }
[ "private", "function", "setAddress", "(", "$", "quoteAddress", ",", "$", "address", ")", "{", "$", "address", "=", "$", "this", "->", "cartHelper", "->", "handleSpecialAddressCases", "(", "$", "address", ")", ";", "$", "region", "=", "$", "this", "->", "...
Set Quote address data helper method. @param Address $quoteAddress @param $address @throws \Exception
[ "Set", "Quote", "address", "data", "helper", "method", "." ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Order.php#L332-L364
train
BoltApp/bolt-magento2
Helper/Order.php
Order.setShippingAddress
private function setShippingAddress($quote, $transaction) { $address = @$transaction->order->cart->shipments[0]->shipping_address; if ($address) { $this->setAddress($quote->getShippingAddress(), $address); } }
php
private function setShippingAddress($quote, $transaction) { $address = @$transaction->order->cart->shipments[0]->shipping_address; if ($address) { $this->setAddress($quote->getShippingAddress(), $address); } }
[ "private", "function", "setShippingAddress", "(", "$", "quote", ",", "$", "transaction", ")", "{", "$", "address", "=", "@", "$", "transaction", "->", "order", "->", "cart", "->", "shipments", "[", "0", "]", "->", "shipping_address", ";", "if", "(", "$",...
Set Quote shipping address data. @param Quote $quote @param $transaction @return void @throws \Exception
[ "Set", "Quote", "shipping", "address", "data", "." ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Order.php#L375-L381
train
BoltApp/bolt-magento2
Helper/Order.php
Order.setBillingAddress
private function setBillingAddress($quote, $transaction) { $address = @$transaction->order->cart->billing_address; if ($address) { $this->setAddress($quote->getBillingAddress(), $address); } }
php
private function setBillingAddress($quote, $transaction) { $address = @$transaction->order->cart->billing_address; if ($address) { $this->setAddress($quote->getBillingAddress(), $address); } }
[ "private", "function", "setBillingAddress", "(", "$", "quote", ",", "$", "transaction", ")", "{", "$", "address", "=", "@", "$", "transaction", "->", "order", "->", "cart", "->", "billing_address", ";", "if", "(", "$", "address", ")", "{", "$", "this", ...
Set Quote billing address data. @param Quote $quote @param $transaction @throws \Exception
[ "Set", "Quote", "billing", "address", "data", "." ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Order.php#L391-L397
train
BoltApp/bolt-magento2
Helper/Order.php
Order.addCustomerDetails
private function addCustomerDetails($quote, $email) { $quote->setCustomerEmail($email); if (!$quote->getCustomerId()) { $quote->setCustomerId(null); $quote->setCheckoutMethod('guest'); $quote->setCustomerIsGuest(true); $quote->setCustomerGroupId(GroupInterface::NOT_LOGGED_IN_ID); } }
php
private function addCustomerDetails($quote, $email) { $quote->setCustomerEmail($email); if (!$quote->getCustomerId()) { $quote->setCustomerId(null); $quote->setCheckoutMethod('guest'); $quote->setCustomerIsGuest(true); $quote->setCustomerGroupId(GroupInterface::NOT_LOGGED_IN_ID); } }
[ "private", "function", "addCustomerDetails", "(", "$", "quote", ",", "$", "email", ")", "{", "$", "quote", "->", "setCustomerEmail", "(", "$", "email", ")", ";", "if", "(", "!", "$", "quote", "->", "getCustomerId", "(", ")", ")", "{", "$", "quote", "...
Set quote customer email and guest checkout parameters @param Quote $quote @param string $email @return void
[ "Set", "quote", "customer", "email", "and", "guest", "checkout", "parameters" ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Order.php#L407-L416
train
BoltApp/bolt-magento2
Helper/Order.php
Order.setPaymentMethod
private function setPaymentMethod($quote) { $quote->setPaymentMethod(Payment::METHOD_CODE); // Set Sales Order Payment $quote->getPayment()->importData(['method' => Payment::METHOD_CODE])->save(); }
php
private function setPaymentMethod($quote) { $quote->setPaymentMethod(Payment::METHOD_CODE); // Set Sales Order Payment $quote->getPayment()->importData(['method' => Payment::METHOD_CODE])->save(); }
[ "private", "function", "setPaymentMethod", "(", "$", "quote", ")", "{", "$", "quote", "->", "setPaymentMethod", "(", "Payment", "::", "METHOD_CODE", ")", ";", "// Set Sales Order Payment", "$", "quote", "->", "getPayment", "(", ")", "->", "importData", "(", "[...
Set Quote payment method, 'boltpay' @param Quote $quote @throws LocalizedException @throws \Exception
[ "Set", "Quote", "payment", "method", "boltpay" ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Order.php#L426-L431
train
BoltApp/bolt-magento2
Helper/Order.php
Order.adjustTaxMismatch
private function adjustTaxMismatch($transaction, $order, $quote) { $boltTaxAmount = round($transaction->order->cart->tax_amount->amount / 100, 2); $boltTotalAmount = round($transaction->order->cart->total_amount->amount / 100, 2); $orderTaxAmount = round($order->getTaxAmount(), 2); if ($boltTaxAmount != $orderTaxAmount) { $order->setTaxAmount($boltTaxAmount); $order->setBaseGrandTotal($boltTotalAmount); $order->setGrandTotal($boltTotalAmount); $this->bugsnag->registerCallback(function ($report) use ($quote, $boltTaxAmount, $orderTaxAmount) { $address = $quote->isVirtual() ? $quote->getBillingAddress() : $quote->getShippingAddress(); $report->setMetaData([ 'TAX MISMATCH' => [ 'Store Applied Taxes' => $address->getAppliedTaxes(), 'Bolt Tax Amount' => $boltTaxAmount, 'Store Tax Amount' => $orderTaxAmount, 'Order #' => $quote->getReservedOrderId(), 'Quote ID' => $quote->getId(), ] ]); }); $diff = round($boltTaxAmount - $orderTaxAmount, 2); $this->bugsnag->notifyError('Tax Mismatch', "Totals adjusted by $diff"); } }
php
private function adjustTaxMismatch($transaction, $order, $quote) { $boltTaxAmount = round($transaction->order->cart->tax_amount->amount / 100, 2); $boltTotalAmount = round($transaction->order->cart->total_amount->amount / 100, 2); $orderTaxAmount = round($order->getTaxAmount(), 2); if ($boltTaxAmount != $orderTaxAmount) { $order->setTaxAmount($boltTaxAmount); $order->setBaseGrandTotal($boltTotalAmount); $order->setGrandTotal($boltTotalAmount); $this->bugsnag->registerCallback(function ($report) use ($quote, $boltTaxAmount, $orderTaxAmount) { $address = $quote->isVirtual() ? $quote->getBillingAddress() : $quote->getShippingAddress(); $report->setMetaData([ 'TAX MISMATCH' => [ 'Store Applied Taxes' => $address->getAppliedTaxes(), 'Bolt Tax Amount' => $boltTaxAmount, 'Store Tax Amount' => $orderTaxAmount, 'Order #' => $quote->getReservedOrderId(), 'Quote ID' => $quote->getId(), ] ]); }); $diff = round($boltTaxAmount - $orderTaxAmount, 2); $this->bugsnag->notifyError('Tax Mismatch', "Totals adjusted by $diff"); } }
[ "private", "function", "adjustTaxMismatch", "(", "$", "transaction", ",", "$", "order", ",", "$", "quote", ")", "{", "$", "boltTaxAmount", "=", "round", "(", "$", "transaction", "->", "order", "->", "cart", "->", "tax_amount", "->", "amount", "/", "100", ...
Check for Tax mismatch between Bolt and Magento. Override store value with the Bolt one if a mismatch was found. @param \stdClass $transaction @param OrderModel $order @param Quote $quote
[ "Check", "for", "Tax", "mismatch", "between", "Bolt", "and", "Magento", ".", "Override", "store", "value", "with", "the", "Bolt", "one", "if", "a", "mismatch", "was", "found", "." ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Order.php#L441-L473
train
BoltApp/bolt-magento2
Helper/Order.php
Order.setQuotePaymentInfoData
private function setQuotePaymentInfoData($quote, $data) { foreach ($data as $key => $value) { $this->getQuotePaymentInfoInstance($quote)->setData($key, $value)->save(); } }
php
private function setQuotePaymentInfoData($quote, $data) { foreach ($data as $key => $value) { $this->getQuotePaymentInfoInstance($quote)->setData($key, $value)->save(); } }
[ "private", "function", "setQuotePaymentInfoData", "(", "$", "quote", ",", "$", "data", ")", "{", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "this", "->", "getQuotePaymentInfoInstance", "(", "$", "quote", ")", "->", ...
Assign data to the quote payment info instance @param Quote $quote @param array $data @return void
[ "Assign", "data", "to", "the", "quote", "payment", "info", "instance" ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Order.php#L600-L605
train
BoltApp/bolt-magento2
Helper/Order.php
Order.getQuotePaymentInfoInstance
private function getQuotePaymentInfoInstance($quote) { return $this->quotePaymentInfoInstance ?: $this->quotePaymentInfoInstance = $quote->getPayment()->getMethodInstance()->getInfoInstance(); }
php
private function getQuotePaymentInfoInstance($quote) { return $this->quotePaymentInfoInstance ?: $this->quotePaymentInfoInstance = $quote->getPayment()->getMethodInstance()->getInfoInstance(); }
[ "private", "function", "getQuotePaymentInfoInstance", "(", "$", "quote", ")", "{", "return", "$", "this", "->", "quotePaymentInfoInstance", "?", ":", "$", "this", "->", "quotePaymentInfoInstance", "=", "$", "quote", "->", "getPayment", "(", ")", "->", "getMethod...
Returns quote payment info object @param Quote $quote @return \Magento\Payment\Model\Info
[ "Returns", "quote", "payment", "info", "object" ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Order.php#L613-L617
train
BoltApp/bolt-magento2
Helper/Order.php
Order.deleteRedundantQuotes
private function deleteRedundantQuotes($quote) { $connection = $this->resourceConnection->getConnection(); // get table name with prefix $tableName = $this->resourceConnection->getTableName('quote'); $sql = "DELETE FROM {$tableName} WHERE bolt_parent_quote_id = :bolt_parent_quote_id AND entity_id != :entity_id"; $bind = [ 'bolt_parent_quote_id' => $quote->getBoltParentQuoteId(), 'entity_id' => $quote->getBoltParentQuoteId() ]; $connection->query($sql, $bind); }
php
private function deleteRedundantQuotes($quote) { $connection = $this->resourceConnection->getConnection(); // get table name with prefix $tableName = $this->resourceConnection->getTableName('quote'); $sql = "DELETE FROM {$tableName} WHERE bolt_parent_quote_id = :bolt_parent_quote_id AND entity_id != :entity_id"; $bind = [ 'bolt_parent_quote_id' => $quote->getBoltParentQuoteId(), 'entity_id' => $quote->getBoltParentQuoteId() ]; $connection->query($sql, $bind); }
[ "private", "function", "deleteRedundantQuotes", "(", "$", "quote", ")", "{", "$", "connection", "=", "$", "this", "->", "resourceConnection", "->", "getConnection", "(", ")", ";", "// get table name with prefix", "$", "tableName", "=", "$", "this", "->", "resour...
Delete redundant immutable quotes. @param Quote $quote
[ "Delete", "redundant", "immutable", "quotes", "." ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Order.php#L624-L638
train
BoltApp/bolt-magento2
Helper/Order.php
Order.setOrderUserNote
public function setOrderUserNote($order, $userNote) { $order ->addStatusHistoryComment($userNote) ->setIsVisibleOnFront(true) ->setIsCustomerNotified(false); return $order; }
php
public function setOrderUserNote($order, $userNote) { $order ->addStatusHistoryComment($userNote) ->setIsVisibleOnFront(true) ->setIsCustomerNotified(false); return $order; }
[ "public", "function", "setOrderUserNote", "(", "$", "order", ",", "$", "userNote", ")", "{", "$", "order", "->", "addStatusHistoryComment", "(", "$", "userNote", ")", "->", "setIsVisibleOnFront", "(", "true", ")", "->", "setIsCustomerNotified", "(", "false", "...
Add user note as status history comment @param OrderModel $order @param string $userNote @return OrderModel
[ "Add", "user", "note", "as", "status", "history", "comment" ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Order.php#L740-L748
train
BoltApp/bolt-magento2
Helper/Order.php
Order.holdOnTotalsMismatch
private function holdOnTotalsMismatch($order, $transaction) { $boltTotal = $transaction->order->cart->total_amount->amount; $storeTotal = round($order->getGrandTotal() * 100); // Stop if no mismatch if ($boltTotal == $storeTotal) { return; } // Put the order ON HOLD and add the status message. // Do it once only, skip on subsequent hooks if ($order->getState() != OrderModel::STATE_HOLDED) { // Put the order on hold $this->setOrderState($order, OrderModel::STATE_HOLDED); // Add order status history comment $comment = __( 'BOLTPAY INFO :: THERE IS A MISMATCH IN THE ORDER PAID AND ORDER RECORDED.<br> Paid amount: %1 Recorded amount: %2<br>Bolt transaction: %3', $boltTotal / 100, $order->getGrandTotal(), $this->formatReferenceUrl($transaction->reference) ); $order->addStatusHistoryComment($comment); $order->save(); } // Get the order and quote id list($incrementId, $quoteId) = array_pad( explode(' / ', $transaction->order->cart->display_id), 2, null ); if (!$quoteId) { $quoteId = $transaction->order->cart->order_reference; } // If the quote exists collect cart data for bugsnag try { $quote = $this->cartHelper->getQuoteById($quoteId); $cart = $this->cartHelper->getCartData(true, false, $quote); } catch (NoSuchEntityException $e) { // Quote was cleaned by cron job $cart = ['The quote does not exist.']; } // Log the debug info $this->bugsnag->registerCallback(function ($report) use ( $transaction, $cart, $incrementId, $boltTotal, $storeTotal ) { $report->setMetaData([ 'TOTALS_MISMATCH' => [ 'Reference' => $transaction->reference, 'Order ID' => $incrementId, 'Bolt Total' => $boltTotal, 'Store Total' => $storeTotal, 'Bolt Cart' => $transaction->order->cart, 'Store Cart' => $cart ] ]); }); throw new LocalizedException(__( 'Order Totals Mismatch Reference: %1 Order: %2 Bolt Total: %3 Store Total: %4', $transaction->reference, $incrementId, $boltTotal, $storeTotal )); }
php
private function holdOnTotalsMismatch($order, $transaction) { $boltTotal = $transaction->order->cart->total_amount->amount; $storeTotal = round($order->getGrandTotal() * 100); // Stop if no mismatch if ($boltTotal == $storeTotal) { return; } // Put the order ON HOLD and add the status message. // Do it once only, skip on subsequent hooks if ($order->getState() != OrderModel::STATE_HOLDED) { // Put the order on hold $this->setOrderState($order, OrderModel::STATE_HOLDED); // Add order status history comment $comment = __( 'BOLTPAY INFO :: THERE IS A MISMATCH IN THE ORDER PAID AND ORDER RECORDED.<br> Paid amount: %1 Recorded amount: %2<br>Bolt transaction: %3', $boltTotal / 100, $order->getGrandTotal(), $this->formatReferenceUrl($transaction->reference) ); $order->addStatusHistoryComment($comment); $order->save(); } // Get the order and quote id list($incrementId, $quoteId) = array_pad( explode(' / ', $transaction->order->cart->display_id), 2, null ); if (!$quoteId) { $quoteId = $transaction->order->cart->order_reference; } // If the quote exists collect cart data for bugsnag try { $quote = $this->cartHelper->getQuoteById($quoteId); $cart = $this->cartHelper->getCartData(true, false, $quote); } catch (NoSuchEntityException $e) { // Quote was cleaned by cron job $cart = ['The quote does not exist.']; } // Log the debug info $this->bugsnag->registerCallback(function ($report) use ( $transaction, $cart, $incrementId, $boltTotal, $storeTotal ) { $report->setMetaData([ 'TOTALS_MISMATCH' => [ 'Reference' => $transaction->reference, 'Order ID' => $incrementId, 'Bolt Total' => $boltTotal, 'Store Total' => $storeTotal, 'Bolt Cart' => $transaction->order->cart, 'Store Cart' => $cart ] ]); }); throw new LocalizedException(__( 'Order Totals Mismatch Reference: %1 Order: %2 Bolt Total: %3 Store Total: %4', $transaction->reference, $incrementId, $boltTotal, $storeTotal )); }
[ "private", "function", "holdOnTotalsMismatch", "(", "$", "order", ",", "$", "transaction", ")", "{", "$", "boltTotal", "=", "$", "transaction", "->", "order", "->", "cart", "->", "total_amount", "->", "amount", ";", "$", "storeTotal", "=", "round", "(", "$...
Record total amount mismatch between magento and bolt order. Log the error in order comments and report via bugsnag. Put the order ON HOLD if it's a mismatch. @param OrderModel $order @param \stdClass $transaction @return bool true if the order was placed on hold, otherwise false
[ "Record", "total", "amount", "mismatch", "between", "magento", "and", "bolt", "order", ".", "Log", "the", "error", "in", "order", "comments", "and", "report", "via", "bugsnag", ".", "Put", "the", "order", "ON", "HOLD", "if", "it", "s", "a", "mismatch", "...
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Order.php#L905-L978
train
BoltApp/bolt-magento2
Helper/Order.php
Order.formatTransactionData
private function formatTransactionData($order, $transaction, $amount) { return [ 'Time' => $this->timezone->formatDateTime( date('Y-m-d H:i:s', $transaction->date / 1000), 2, 2 ), 'Reference' => $transaction->reference, 'Amount' => $order->getBaseCurrency()->formatTxt($amount / 100), 'Transaction ID' => $transaction->id ]; }
php
private function formatTransactionData($order, $transaction, $amount) { return [ 'Time' => $this->timezone->formatDateTime( date('Y-m-d H:i:s', $transaction->date / 1000), 2, 2 ), 'Reference' => $transaction->reference, 'Amount' => $order->getBaseCurrency()->formatTxt($amount / 100), 'Transaction ID' => $transaction->id ]; }
[ "private", "function", "formatTransactionData", "(", "$", "order", ",", "$", "transaction", ",", "$", "amount", ")", "{", "return", "[", "'Time'", "=>", "$", "this", "->", "timezone", "->", "formatDateTime", "(", "date", "(", "'Y-m-d H:i:s'", ",", "$", "tr...
Generate data to be stored with the transaction @param OrderModel $order @param \stdClass $transaction @param null|int $amount
[ "Generate", "data", "to", "be", "stored", "with", "the", "transaction" ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Order.php#L1008-L1020
train
BoltApp/bolt-magento2
Helper/Order.php
Order.setOrderState
private function setOrderState($order, $state) { $prevState = $order->getState(); if ($state == OrderModel::STATE_HOLDED) { // Ensure order is in one of the "can hold" states [STATE_NEW | STATE_PROCESSING] // to avoid no state on admin order unhold if ($prevState != OrderModel::STATE_NEW) { $order->setState(OrderModel::STATE_PROCESSING); $order->setStatus($order->getConfig()->getStateDefaultStatus(OrderModel::STATE_PROCESSING)); } try { $order->hold(); } catch (\Exception $e) { // Put the order in "on hold" state even if the previous call fails $order->setState(OrderModel::STATE_HOLDED); $order->setStatus($order->getConfig()->getStateDefaultStatus(OrderModel::STATE_HOLDED)); } } elseif ($state == OrderModel::STATE_CANCELED) { try { $order->cancel(); $order->setState(OrderModel::STATE_CANCELED); $order->setStatus($order->getConfig()->getStateDefaultStatus(OrderModel::STATE_CANCELED)); } catch (\Exception $e) { // Put the order in "canceled" state even if the previous call fails $order->setState(OrderModel::STATE_CANCELED); $order->setStatus($order->getConfig()->getStateDefaultStatus(OrderModel::STATE_CANCELED)); } } else { $order->setState($state); $order->setStatus($order->getConfig()->getStateDefaultStatus($state)); } }
php
private function setOrderState($order, $state) { $prevState = $order->getState(); if ($state == OrderModel::STATE_HOLDED) { // Ensure order is in one of the "can hold" states [STATE_NEW | STATE_PROCESSING] // to avoid no state on admin order unhold if ($prevState != OrderModel::STATE_NEW) { $order->setState(OrderModel::STATE_PROCESSING); $order->setStatus($order->getConfig()->getStateDefaultStatus(OrderModel::STATE_PROCESSING)); } try { $order->hold(); } catch (\Exception $e) { // Put the order in "on hold" state even if the previous call fails $order->setState(OrderModel::STATE_HOLDED); $order->setStatus($order->getConfig()->getStateDefaultStatus(OrderModel::STATE_HOLDED)); } } elseif ($state == OrderModel::STATE_CANCELED) { try { $order->cancel(); $order->setState(OrderModel::STATE_CANCELED); $order->setStatus($order->getConfig()->getStateDefaultStatus(OrderModel::STATE_CANCELED)); } catch (\Exception $e) { // Put the order in "canceled" state even if the previous call fails $order->setState(OrderModel::STATE_CANCELED); $order->setStatus($order->getConfig()->getStateDefaultStatus(OrderModel::STATE_CANCELED)); } } else { $order->setState($state); $order->setStatus($order->getConfig()->getStateDefaultStatus($state)); } }
[ "private", "function", "setOrderState", "(", "$", "order", ",", "$", "state", ")", "{", "$", "prevState", "=", "$", "order", "->", "getState", "(", ")", ";", "if", "(", "$", "state", "==", "OrderModel", "::", "STATE_HOLDED", ")", "{", "// Ensure order is...
Change order state taking transition constraints into account. @param OrderModel $order @param string $state
[ "Change", "order", "state", "taking", "transition", "constraints", "into", "account", "." ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Order.php#L1046-L1077
train
BoltApp/bolt-magento2
Helper/Order.php
Order.checkPaymentMethod
private function checkPaymentMethod($payment) { $paymentMethod = $payment->getMethod(); if ($paymentMethod != Payment::METHOD_CODE) { throw new LocalizedException(__( 'Payment method assigned to order is: %1', $paymentMethod )); } }
php
private function checkPaymentMethod($payment) { $paymentMethod = $payment->getMethod(); if ($paymentMethod != Payment::METHOD_CODE) { throw new LocalizedException(__( 'Payment method assigned to order is: %1', $paymentMethod )); } }
[ "private", "function", "checkPaymentMethod", "(", "$", "payment", ")", "{", "$", "paymentMethod", "=", "$", "payment", "->", "getMethod", "(", ")", ";", "if", "(", "$", "paymentMethod", "!=", "Payment", "::", "METHOD_CODE", ")", "{", "throw", "new", "Local...
Check if order payment method was set to 'boltpay' @param OrderPaymentInterface $payment @throws LocalizedException
[ "Check", "if", "order", "payment", "method", "was", "set", "to", "boltpay" ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Order.php#L1085-L1095
train
BoltApp/bolt-magento2
Helper/Order.php
Order.createOrderInvoice
private function createOrderInvoice($order, $transactionId, $amount) { if ($order->getTotalInvoiced() + $amount == $order->getGrandTotal()) { $invoice = $this->invoiceService->prepareInvoice($order); } else { $invoice = $this->invoiceService->prepareInvoiceWithoutItems($order, $amount); } $invoice->setRequestedCaptureCase(Invoice::CAPTURE_OFFLINE); $invoice->setTransactionId($transactionId); $invoice->setBaseGrandTotal($amount); $invoice->setGrandTotal($amount); $invoice->register(); $invoice->save(); $order->addRelatedObject($invoice); if (!$invoice->getEmailSent()) { $this->invoiceSender->send($invoice); } //Add notification comment to order $order->addStatusHistoryComment( __('Invoice #%1 is created. Notification email is sent to customer.', $invoice->getId()) )->setIsCustomerNotified(true)->save(); return $invoice; }
php
private function createOrderInvoice($order, $transactionId, $amount) { if ($order->getTotalInvoiced() + $amount == $order->getGrandTotal()) { $invoice = $this->invoiceService->prepareInvoice($order); } else { $invoice = $this->invoiceService->prepareInvoiceWithoutItems($order, $amount); } $invoice->setRequestedCaptureCase(Invoice::CAPTURE_OFFLINE); $invoice->setTransactionId($transactionId); $invoice->setBaseGrandTotal($amount); $invoice->setGrandTotal($amount); $invoice->register(); $invoice->save(); $order->addRelatedObject($invoice); if (!$invoice->getEmailSent()) { $this->invoiceSender->send($invoice); } //Add notification comment to order $order->addStatusHistoryComment( __('Invoice #%1 is created. Notification email is sent to customer.', $invoice->getId()) )->setIsCustomerNotified(true)->save(); return $invoice; }
[ "private", "function", "createOrderInvoice", "(", "$", "order", ",", "$", "transactionId", ",", "$", "amount", ")", "{", "if", "(", "$", "order", "->", "getTotalInvoiced", "(", ")", "+", "$", "amount", "==", "$", "order", "->", "getGrandTotal", "(", ")",...
Create an invoice for the order. @param OrderModel $order @param string $transactionId @param float $amount @return bool @throws \Exception @throws LocalizedException
[ "Create", "an", "invoice", "for", "the", "order", "." ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Order.php#L1352-L1379
train
BoltApp/bolt-magento2
Model/Service/InvoiceService.php
InvoiceService.prepareInvoiceWithoutItems
public function prepareInvoiceWithoutItems(OrderInterface $order, $amount) { try { $invoice = $this->orderConverter->toInvoice($order); $invoice->setBaseGrandTotal($amount); $invoice->setSubtotal($amount); $invoice->setBaseSubtotal($amount); $invoice->setGrandTotal($amount); $order->getInvoiceCollection()->addItem($invoice); return $invoice; } catch(\Exception $e) { $this->bugsnag->notifyException($e); throw $e; } }
php
public function prepareInvoiceWithoutItems(OrderInterface $order, $amount) { try { $invoice = $this->orderConverter->toInvoice($order); $invoice->setBaseGrandTotal($amount); $invoice->setSubtotal($amount); $invoice->setBaseSubtotal($amount); $invoice->setGrandTotal($amount); $order->getInvoiceCollection()->addItem($invoice); return $invoice; } catch(\Exception $e) { $this->bugsnag->notifyException($e); throw $e; } }
[ "public", "function", "prepareInvoiceWithoutItems", "(", "OrderInterface", "$", "order", ",", "$", "amount", ")", "{", "try", "{", "$", "invoice", "=", "$", "this", "->", "orderConverter", "->", "toInvoice", "(", "$", "order", ")", ";", "$", "invoice", "->...
Prepare order invoice without any items @param \Magento\Sales\Api\Data\OrderInterface $order @param $amount @return \Magento\Sales\Model\Order\Invoice @throws \Exception
[ "Prepare", "order", "invoice", "without", "any", "items" ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Model/Service/InvoiceService.php#L49-L65
train
BoltApp/bolt-magento2
Model/Api/OrderManagement.php
OrderManagement.manage
public function manage( $id = null, $reference, $order = null, $type = null, $amount = null, $currency = null, $status = null, $display_id = null, $source_transaction_id = null, $source_transaction_reference = null ) { try { HookHelper::$fromBolt = true; $this->logHelper->addInfoLog($this->request->getContent()); $this->hookHelper->setCommonMetaData(); $this->hookHelper->setHeaders(); $this->hookHelper->verifyWebhook(); if (empty($reference)) { throw new LocalizedException( __('Missing required parameters.') ); } $this->orderHelper->saveUpdateOrder( $reference, $this->request->getHeader(ConfigHelper::BOLT_TRACE_ID_HEADER), $type ); $this->response->setHttpResponseCode(200); $this->response->setBody(json_encode([ 'status' => 'success', 'message' => 'Order creation / upadte was successful', ])); } catch (\Magento\Framework\Webapi\Exception $e) { $this->bugsnag->notifyException($e); $this->response->setHttpResponseCode($e->getHttpCode()); $this->response->setBody(json_encode([ 'status' => 'error', 'code' => $e->getCode(), 'message' => $e->getMessage(), ])); } catch (\Exception $e) { $this->bugsnag->notifyException($e); $this->response->setHttpResponseCode(422); $this->response->setBody(json_encode([ 'status' => 'error', 'code' => '6009', 'message' => 'Unprocessable Entity: ' . $e->getMessage(), ])); } finally { $this->response->sendResponse(); } }
php
public function manage( $id = null, $reference, $order = null, $type = null, $amount = null, $currency = null, $status = null, $display_id = null, $source_transaction_id = null, $source_transaction_reference = null ) { try { HookHelper::$fromBolt = true; $this->logHelper->addInfoLog($this->request->getContent()); $this->hookHelper->setCommonMetaData(); $this->hookHelper->setHeaders(); $this->hookHelper->verifyWebhook(); if (empty($reference)) { throw new LocalizedException( __('Missing required parameters.') ); } $this->orderHelper->saveUpdateOrder( $reference, $this->request->getHeader(ConfigHelper::BOLT_TRACE_ID_HEADER), $type ); $this->response->setHttpResponseCode(200); $this->response->setBody(json_encode([ 'status' => 'success', 'message' => 'Order creation / upadte was successful', ])); } catch (\Magento\Framework\Webapi\Exception $e) { $this->bugsnag->notifyException($e); $this->response->setHttpResponseCode($e->getHttpCode()); $this->response->setBody(json_encode([ 'status' => 'error', 'code' => $e->getCode(), 'message' => $e->getMessage(), ])); } catch (\Exception $e) { $this->bugsnag->notifyException($e); $this->response->setHttpResponseCode(422); $this->response->setBody(json_encode([ 'status' => 'error', 'code' => '6009', 'message' => 'Unprocessable Entity: ' . $e->getMessage(), ])); } finally { $this->response->sendResponse(); } }
[ "public", "function", "manage", "(", "$", "id", "=", "null", ",", "$", "reference", ",", "$", "order", "=", "null", ",", "$", "type", "=", "null", ",", "$", "amount", "=", "null", ",", "$", "currency", "=", "null", ",", "$", "status", "=", "null"...
Manage order. @api @param mixed $id @param mixed $reference @param mixed $order @param mixed $type @param mixed $amount @param mixed $currency @param mixed $status @param mixed $display_id @param mixed $source_transaction_id @param mixed $source_transaction_reference @return void @throws \Exception
[ "Manage", "order", "." ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Model/Api/OrderManagement.php#L119-L175
train
BoltApp/bolt-magento2
Helper/Hook.php
Hook.verifyWebhookApi
private function verifyWebhookApi($payload, $hmac_header) { //Request Data $requestData = $this->dataObjectFactory->create(); $requestData->setApiData(json_decode($payload)); $requestData->setDynamicApiUrl(ApiHelper::API_VERIFY_SIGNATURE); $requestData->setApiKey($this->configHelper->getApiKey()); $headers = [ self::HMAC_HEADER => $hmac_header ]; $requestData->setHeaders($headers); $requestData->setStatusOnly(true); //Build Request $request = $this->apiHelper->buildRequest($requestData); try { $result = $this->apiHelper->sendRequest($request); } catch (\Exception $e) { return false; } return $result == 200; }
php
private function verifyWebhookApi($payload, $hmac_header) { //Request Data $requestData = $this->dataObjectFactory->create(); $requestData->setApiData(json_decode($payload)); $requestData->setDynamicApiUrl(ApiHelper::API_VERIFY_SIGNATURE); $requestData->setApiKey($this->configHelper->getApiKey()); $headers = [ self::HMAC_HEADER => $hmac_header ]; $requestData->setHeaders($headers); $requestData->setStatusOnly(true); //Build Request $request = $this->apiHelper->buildRequest($requestData); try { $result = $this->apiHelper->sendRequest($request); } catch (\Exception $e) { return false; } return $result == 200; }
[ "private", "function", "verifyWebhookApi", "(", "$", "payload", ",", "$", "hmac_header", ")", "{", "//Request Data", "$", "requestData", "=", "$", "this", "->", "dataObjectFactory", "->", "create", "(", ")", ";", "$", "requestData", "->", "setApiData", "(", ...
Verifying Hook Requests via API call. @param string $payload @param string $hmac_header @return bool @throws \Magento\Framework\Exception\LocalizedException
[ "Verifying", "Hook", "Requests", "via", "API", "call", "." ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Hook.php#L115-L140
train
BoltApp/bolt-magento2
Helper/Hook.php
Hook.verifyWebhookSecret
public function verifyWebhookSecret($payload, $hmac_header) { $signing_secret = $this->configHelper->getSigningSecret(); $computed_hmac = base64_encode(hash_hmac('sha256', $payload, $signing_secret, true)); return $computed_hmac == $hmac_header; }
php
public function verifyWebhookSecret($payload, $hmac_header) { $signing_secret = $this->configHelper->getSigningSecret(); $computed_hmac = base64_encode(hash_hmac('sha256', $payload, $signing_secret, true)); return $computed_hmac == $hmac_header; }
[ "public", "function", "verifyWebhookSecret", "(", "$", "payload", ",", "$", "hmac_header", ")", "{", "$", "signing_secret", "=", "$", "this", "->", "configHelper", "->", "getSigningSecret", "(", ")", ";", "$", "computed_hmac", "=", "base64_encode", "(", "hash_...
Verifying Hook Request using pre-exchanged signing secret key. @param string $payload @param string $hmac_header @return bool
[ "Verifying", "Hook", "Request", "using", "pre", "-", "exchanged", "signing", "secret", "key", "." ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Hook.php#L150-L156
train
BoltApp/bolt-magento2
Helper/Hook.php
Hook.verifyWebhook
public function verifyWebhook() { $payload = $this->request->getContent(); $hmac_header = $this->request->getHeader(self::HMAC_HEADER); if (!$this->verifyWebhookSecret($payload, $hmac_header) && !$this->verifyWebhookApi($payload, $hmac_header)) { throw new WebapiException(__('Precondition Failed'), 6001, 412); } }
php
public function verifyWebhook() { $payload = $this->request->getContent(); $hmac_header = $this->request->getHeader(self::HMAC_HEADER); if (!$this->verifyWebhookSecret($payload, $hmac_header) && !$this->verifyWebhookApi($payload, $hmac_header)) { throw new WebapiException(__('Precondition Failed'), 6001, 412); } }
[ "public", "function", "verifyWebhook", "(", ")", "{", "$", "payload", "=", "$", "this", "->", "request", "->", "getContent", "(", ")", ";", "$", "hmac_header", "=", "$", "this", "->", "request", "->", "getHeader", "(", "self", "::", "HMAC_HEADER", ")", ...
Verifying Hook Request. If signing secret is not defined or fails fallback to api call. @throws WebapiException @throws \Magento\Framework\Exception\LocalizedException
[ "Verifying", "Hook", "Request", ".", "If", "signing", "secret", "is", "not", "defined", "or", "fails", "fallback", "to", "api", "call", "." ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Hook.php#L164-L172
train
BoltApp/bolt-magento2
Helper/Hook.php
Hook.setCommonMetaData
public function setCommonMetaData() { if ($boltTraceId = $this->request->getHeader(ConfigHelper::BOLT_TRACE_ID_HEADER)) { $this->bugsnag->registerCallback(function ($report) use ($boltTraceId) { $report->setMetaData([ 'META DATA' => [ 'bolt_trace_id' => $boltTraceId, ] ]); }); } }
php
public function setCommonMetaData() { if ($boltTraceId = $this->request->getHeader(ConfigHelper::BOLT_TRACE_ID_HEADER)) { $this->bugsnag->registerCallback(function ($report) use ($boltTraceId) { $report->setMetaData([ 'META DATA' => [ 'bolt_trace_id' => $boltTraceId, ] ]); }); } }
[ "public", "function", "setCommonMetaData", "(", ")", "{", "if", "(", "$", "boltTraceId", "=", "$", "this", "->", "request", "->", "getHeader", "(", "ConfigHelper", "::", "BOLT_TRACE_ID_HEADER", ")", ")", "{", "$", "this", "->", "bugsnag", "->", "registerCall...
Set bugsnag metadata bolt_trace_id
[ "Set", "bugsnag", "metadata", "bolt_trace_id" ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Hook.php#L177-L188
train
BoltApp/bolt-magento2
Helper/Hook.php
Hook.setHeaders
public function setHeaders() { $this->response->getHeaders()->addHeaders([ 'User-Agent' => 'BoltPay/Magento-'.$this->configHelper->getStoreVersion() . '/' . $this->configHelper->getModuleVersion(), 'X-Bolt-Plugin-Version' => $this->configHelper->getModuleVersion(), ]); }
php
public function setHeaders() { $this->response->getHeaders()->addHeaders([ 'User-Agent' => 'BoltPay/Magento-'.$this->configHelper->getStoreVersion() . '/' . $this->configHelper->getModuleVersion(), 'X-Bolt-Plugin-Version' => $this->configHelper->getModuleVersion(), ]); }
[ "public", "function", "setHeaders", "(", ")", "{", "$", "this", "->", "response", "->", "getHeaders", "(", ")", "->", "addHeaders", "(", "[", "'User-Agent'", "=>", "'BoltPay/Magento-'", ".", "$", "this", "->", "configHelper", "->", "getStoreVersion", "(", ")...
Set additional response headers
[ "Set", "additional", "response", "headers" ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Hook.php#L193-L199
train
BoltApp/bolt-magento2
Helper/Discount.php
Discount.updateTotals
private function updateTotals(Quote $quote) { $quote->getShippingAddress()->setCollectShippingRates(true); $quote->setTotalsCollectedFlag(false); $quote->collectTotals(); $quote->setDataChanges(true); $this->quoteRepository->save($quote); }
php
private function updateTotals(Quote $quote) { $quote->getShippingAddress()->setCollectShippingRates(true); $quote->setTotalsCollectedFlag(false); $quote->collectTotals(); $quote->setDataChanges(true); $this->quoteRepository->save($quote); }
[ "private", "function", "updateTotals", "(", "Quote", "$", "quote", ")", "{", "$", "quote", "->", "getShippingAddress", "(", ")", "->", "setCollectShippingRates", "(", "true", ")", ";", "$", "quote", "->", "setTotalsCollectedFlag", "(", "false", ")", ";", "$"...
Collect and update quote totals. @param Quote $quote
[ "Collect", "and", "update", "quote", "totals", "." ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Discount.php#L158-L165
train
BoltApp/bolt-magento2
Helper/Discount.php
Discount.loadAmastyGiftCard
public function loadAmastyGiftCard($code) { try { if (!$this->isAmastyGiftCardAvailable()) { return null; } $accountModel = $this->amastyAccountFactory->getInstance() ->create() ->loadByCode($code); return $accountModel && $accountModel->getId() ? $accountModel : null; } catch (\Exception $e) { return null; } }
php
public function loadAmastyGiftCard($code) { try { if (!$this->isAmastyGiftCardAvailable()) { return null; } $accountModel = $this->amastyAccountFactory->getInstance() ->create() ->loadByCode($code); return $accountModel && $accountModel->getId() ? $accountModel : null; } catch (\Exception $e) { return null; } }
[ "public", "function", "loadAmastyGiftCard", "(", "$", "code", ")", "{", "try", "{", "if", "(", "!", "$", "this", "->", "isAmastyGiftCardAvailable", "(", ")", ")", "{", "return", "null", ";", "}", "$", "accountModel", "=", "$", "this", "->", "amastyAccoun...
Load Amasty Gift Card account object. @param string $code Gift Card coupon code @return \Amasty\GiftCard\Model\Account|null
[ "Load", "Amasty", "Gift", "Card", "account", "object", "." ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Discount.php#L172-L186
train
BoltApp/bolt-magento2
Helper/Discount.php
Discount.applyAmastyGiftCard
public function applyAmastyGiftCard($code, $accountModel, $quote) { // Get current gift card balance before applying it to the quote // in case "fixed_amount" / "pay for everything" discount type is used $giftAmount = $accountModel->getCurrentValue(); $quoteId = $quote->getId(); $isValid = $this->amastyGiftCardManagement->getInstance()->validateCode($quote, $code); if (!$isValid) { throw new LocalizedException(__('Coupon with specified code "%1" is not valid.', $code)); } if ($accountModel->canApplyCardForQuote($quote)) { $quoteGiftCard = $this->amastyQuoteFactory->getInstance()->create(); $this->amastyQuoteResource->getInstance()->load($quoteGiftCard, $quoteId, 'quote_id'); $subtotal = $quoteGiftCard->getSubtotal($quote); if ($quoteGiftCard->getCodeId() && $accountModel->getCodeId() == $quoteGiftCard->getCodeId()) { throw new LocalizedException(__('This gift card account is already in the quote.')); } elseif ($quoteGiftCard->getGiftAmount() && $subtotal == $quoteGiftCard->getGiftAmount()) { throw new LocalizedException(__('Gift card can\'t be applied. Maximum discount reached.')); } else { $quoteGiftCard->unsetData($quoteGiftCard->getIdFieldName()); $quoteGiftCard->setQuoteId($quoteId); $quoteGiftCard->setCodeId($accountModel->getCodeId()); $quoteGiftCard->setAccountId($accountModel->getId()); $this->amastyQuoteRepository->getInstance()->save($quoteGiftCard); $this->updateTotals($quote); if ($this->getAmastyPayForEverything()) { // pay for everything, items, shipping, tax return $giftAmount; } else { // pay for items only $totals = $quote->getTotals(); return $totals[self::AMASTY_GIFTCARD]->getValue(); } } } else { throw new LocalizedException(__('Gift card can\'t be applied.')); } }
php
public function applyAmastyGiftCard($code, $accountModel, $quote) { // Get current gift card balance before applying it to the quote // in case "fixed_amount" / "pay for everything" discount type is used $giftAmount = $accountModel->getCurrentValue(); $quoteId = $quote->getId(); $isValid = $this->amastyGiftCardManagement->getInstance()->validateCode($quote, $code); if (!$isValid) { throw new LocalizedException(__('Coupon with specified code "%1" is not valid.', $code)); } if ($accountModel->canApplyCardForQuote($quote)) { $quoteGiftCard = $this->amastyQuoteFactory->getInstance()->create(); $this->amastyQuoteResource->getInstance()->load($quoteGiftCard, $quoteId, 'quote_id'); $subtotal = $quoteGiftCard->getSubtotal($quote); if ($quoteGiftCard->getCodeId() && $accountModel->getCodeId() == $quoteGiftCard->getCodeId()) { throw new LocalizedException(__('This gift card account is already in the quote.')); } elseif ($quoteGiftCard->getGiftAmount() && $subtotal == $quoteGiftCard->getGiftAmount()) { throw new LocalizedException(__('Gift card can\'t be applied. Maximum discount reached.')); } else { $quoteGiftCard->unsetData($quoteGiftCard->getIdFieldName()); $quoteGiftCard->setQuoteId($quoteId); $quoteGiftCard->setCodeId($accountModel->getCodeId()); $quoteGiftCard->setAccountId($accountModel->getId()); $this->amastyQuoteRepository->getInstance()->save($quoteGiftCard); $this->updateTotals($quote); if ($this->getAmastyPayForEverything()) { // pay for everything, items, shipping, tax return $giftAmount; } else { // pay for items only $totals = $quote->getTotals(); return $totals[self::AMASTY_GIFTCARD]->getValue(); } } } else { throw new LocalizedException(__('Gift card can\'t be applied.')); } }
[ "public", "function", "applyAmastyGiftCard", "(", "$", "code", ",", "$", "accountModel", ",", "$", "quote", ")", "{", "// Get current gift card balance before applying it to the quote", "// in case \"fixed_amount\" / \"pay for everything\" discount type is used", "$", "giftAmount",...
Apply Amasty Gift Card coupon to cart @param string $code Gift Card coupon code @param \Amasty\GiftCard\Model\Account $accountModel @param Quote $quote @return float @throws LocalizedException
[ "Apply", "Amasty", "Gift", "Card", "coupon", "to", "cart" ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Discount.php#L197-L245
train
BoltApp/bolt-magento2
Helper/Discount.php
Discount.cloneAmastyGiftCards
public function cloneAmastyGiftCards($sourceQuoteId, $destinationQuoteId) { if (! $this->isAmastyGiftCardAvailable()) { return; } $connection = $this->resource->getConnection(); $connection->beginTransaction(); try { $giftCardTable = $this->resource->getTableName('amasty_amgiftcard_quote'); // Clear previously applied gift cart codes from the immutable quote $sql = "DELETE FROM {$giftCardTable} WHERE quote_id = :destination_quote_id"; $connection->query($sql, ['destination_quote_id' => $destinationQuoteId]); // Copy all gift cart codes applied to the parent quote to the immutable quote $sql = "INSERT INTO {$giftCardTable} (quote_id, code_id, account_id, base_gift_amount, code) SELECT :destination_quote_id, code_id, account_id, base_gift_amount, code FROM {$giftCardTable} WHERE quote_id = :source_quote_id"; $connection->query($sql, ['destination_quote_id' => $destinationQuoteId, 'source_quote_id' => $sourceQuoteId]); $connection->commit(); } catch (\Zend_Db_Statement_Exception $e) { $connection->rollBack(); $this->bugsnag->notifyException($e); } }
php
public function cloneAmastyGiftCards($sourceQuoteId, $destinationQuoteId) { if (! $this->isAmastyGiftCardAvailable()) { return; } $connection = $this->resource->getConnection(); $connection->beginTransaction(); try { $giftCardTable = $this->resource->getTableName('amasty_amgiftcard_quote'); // Clear previously applied gift cart codes from the immutable quote $sql = "DELETE FROM {$giftCardTable} WHERE quote_id = :destination_quote_id"; $connection->query($sql, ['destination_quote_id' => $destinationQuoteId]); // Copy all gift cart codes applied to the parent quote to the immutable quote $sql = "INSERT INTO {$giftCardTable} (quote_id, code_id, account_id, base_gift_amount, code) SELECT :destination_quote_id, code_id, account_id, base_gift_amount, code FROM {$giftCardTable} WHERE quote_id = :source_quote_id"; $connection->query($sql, ['destination_quote_id' => $destinationQuoteId, 'source_quote_id' => $sourceQuoteId]); $connection->commit(); } catch (\Zend_Db_Statement_Exception $e) { $connection->rollBack(); $this->bugsnag->notifyException($e); } }
[ "public", "function", "cloneAmastyGiftCards", "(", "$", "sourceQuoteId", ",", "$", "destinationQuoteId", ")", "{", "if", "(", "!", "$", "this", "->", "isAmastyGiftCardAvailable", "(", ")", ")", "{", "return", ";", "}", "$", "connection", "=", "$", "this", ...
Copy Amasty Gift Cart data from source to destination quote @param int|string $sourceQuoteId @param int|string $destinationQuoteId
[ "Copy", "Amasty", "Gift", "Cart", "data", "from", "source", "to", "destination", "quote" ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Discount.php#L253-L278
train
BoltApp/bolt-magento2
Helper/Discount.php
Discount.deleteRedundantAmastyGiftCards
public function deleteRedundantAmastyGiftCards($quote) { if (! $this->isAmastyGiftCardAvailable()) { return; } $connection = $this->resource->getConnection(); try { $giftCardTable = $this->resource->getTableName('amasty_amgiftcard_quote'); $quoteTable = $this->resource->getTableName('quote'); $sql = "DELETE FROM {$giftCardTable} WHERE quote_id IN (SELECT entity_id FROM {$quoteTable} WHERE bolt_parent_quote_id = :bolt_parent_quote_id AND entity_id != :entity_id)"; $bind = [ 'bolt_parent_quote_id' => $quote->getBoltParentQuoteId(), 'entity_id' => $quote->getBoltParentQuoteId() ]; $connection->query($sql, $bind); } catch (\Zend_Db_Statement_Exception $e) { $this->bugsnag->notifyException($e); } }
php
public function deleteRedundantAmastyGiftCards($quote) { if (! $this->isAmastyGiftCardAvailable()) { return; } $connection = $this->resource->getConnection(); try { $giftCardTable = $this->resource->getTableName('amasty_amgiftcard_quote'); $quoteTable = $this->resource->getTableName('quote'); $sql = "DELETE FROM {$giftCardTable} WHERE quote_id IN (SELECT entity_id FROM {$quoteTable} WHERE bolt_parent_quote_id = :bolt_parent_quote_id AND entity_id != :entity_id)"; $bind = [ 'bolt_parent_quote_id' => $quote->getBoltParentQuoteId(), 'entity_id' => $quote->getBoltParentQuoteId() ]; $connection->query($sql, $bind); } catch (\Zend_Db_Statement_Exception $e) { $this->bugsnag->notifyException($e); } }
[ "public", "function", "deleteRedundantAmastyGiftCards", "(", "$", "quote", ")", "{", "if", "(", "!", "$", "this", "->", "isAmastyGiftCardAvailable", "(", ")", ")", "{", "return", ";", "}", "$", "connection", "=", "$", "this", "->", "resource", "->", "getCo...
Try to clear Amasty Gift Cart data for the unused immutable quotes @param Quote $quote parent quote
[ "Try", "to", "clear", "Amasty", "Gift", "Cart", "data", "for", "the", "unused", "immutable", "quotes" ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Discount.php#L285-L307
train
BoltApp/bolt-magento2
Helper/Discount.php
Discount.removeAmastyGiftCard
public function removeAmastyGiftCard($codeId, $quote) { if (! $this->isAmastyGiftCardAvailable()) { return; } $connection = $this->resource->getConnection(); try { $giftCardTable = $this->resource->getTableName('amasty_amgiftcard_quote'); $sql = "DELETE FROM {$giftCardTable} WHERE code_id = :code_id AND quote_id = :quote_id"; $connection->query($sql, ['code_id' => $codeId, 'quote_id' => $quote->getId()]); $this->updateTotals($quote); } catch (\Zend_Db_Statement_Exception $e) { $this->bugsnag->notifyException($e); } }
php
public function removeAmastyGiftCard($codeId, $quote) { if (! $this->isAmastyGiftCardAvailable()) { return; } $connection = $this->resource->getConnection(); try { $giftCardTable = $this->resource->getTableName('amasty_amgiftcard_quote'); $sql = "DELETE FROM {$giftCardTable} WHERE code_id = :code_id AND quote_id = :quote_id"; $connection->query($sql, ['code_id' => $codeId, 'quote_id' => $quote->getId()]); $this->updateTotals($quote); } catch (\Zend_Db_Statement_Exception $e) { $this->bugsnag->notifyException($e); } }
[ "public", "function", "removeAmastyGiftCard", "(", "$", "codeId", ",", "$", "quote", ")", "{", "if", "(", "!", "$", "this", "->", "isAmastyGiftCardAvailable", "(", ")", ")", "{", "return", ";", "}", "$", "connection", "=", "$", "this", "->", "resource", ...
Remove Amasty Gift Card and update quote totals @param int $codeId @param Quote $quote
[ "Remove", "Amasty", "Gift", "Card", "and", "update", "quote", "totals" ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Discount.php#L315-L331
train
BoltApp/bolt-magento2
Helper/Discount.php
Discount.getAmastyGiftCardCodesFromTotals
public function getAmastyGiftCardCodesFromTotals($totals) { $giftCardCodes = explode(',', $totals[self::AMASTY_GIFTCARD]->getTitle()); return array_map('trim', $giftCardCodes); }
php
public function getAmastyGiftCardCodesFromTotals($totals) { $giftCardCodes = explode(',', $totals[self::AMASTY_GIFTCARD]->getTitle()); return array_map('trim', $giftCardCodes); }
[ "public", "function", "getAmastyGiftCardCodesFromTotals", "(", "$", "totals", ")", "{", "$", "giftCardCodes", "=", "explode", "(", "','", ",", "$", "totals", "[", "self", "::", "AMASTY_GIFTCARD", "]", "->", "getTitle", "(", ")", ")", ";", "return", "array_ma...
Get Amasty Gift Card codes, stored comma separated in total title field, return as array. @param array $totals totals array collected from quote @return array
[ "Get", "Amasty", "Gift", "Card", "codes", "stored", "comma", "separated", "in", "total", "title", "field", "return", "as", "array", "." ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Discount.php#L357-L361
train
BoltApp/bolt-magento2
Helper/Discount.php
Discount.getAmastyGiftCardCodesCurrentValue
public function getAmastyGiftCardCodesCurrentValue($giftCardCodes) { $data = $this->amastyAccountCollection ->getInstance() ->joinCode() ->addFieldToFilter('gift_code', ['in'=>$giftCardCodes]) ->getData(); return array_sum(array_column($data, 'current_value')); }
php
public function getAmastyGiftCardCodesCurrentValue($giftCardCodes) { $data = $this->amastyAccountCollection ->getInstance() ->joinCode() ->addFieldToFilter('gift_code', ['in'=>$giftCardCodes]) ->getData(); return array_sum(array_column($data, 'current_value')); }
[ "public", "function", "getAmastyGiftCardCodesCurrentValue", "(", "$", "giftCardCodes", ")", "{", "$", "data", "=", "$", "this", "->", "amastyAccountCollection", "->", "getInstance", "(", ")", "->", "joinCode", "(", ")", "->", "addFieldToFilter", "(", "'gift_code'"...
Get accumulated unused balance of all Amasty Gift Cards corresponding to passed gift card coupons array @param array $giftCardCodes @return float|int|mixed
[ "Get", "accumulated", "unused", "balance", "of", "all", "Amasty", "Gift", "Cards", "corresponding", "to", "passed", "gift", "card", "coupons", "array" ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Discount.php#L369-L378
train
BoltApp/bolt-magento2
Helper/Discount.php
Discount.getUnirgyGiftCertBalanceByCode
public function getUnirgyGiftCertBalanceByCode($giftcertCode) { /** @var \Unirgy\Giftcert\Model\Cert $giftCert */ $unirgyInstance = $this->unirgyCertRepository->getInstance(); $result = 0; if ($unirgyInstance) { $giftCert = $unirgyInstance->get($giftcertCode); if ($giftCert && $giftCert->getStatus() === 'A' && $giftCert->getBalance() > 0) { $result = $giftCert->getBalance(); } } return (float) $result; }
php
public function getUnirgyGiftCertBalanceByCode($giftcertCode) { /** @var \Unirgy\Giftcert\Model\Cert $giftCert */ $unirgyInstance = $this->unirgyCertRepository->getInstance(); $result = 0; if ($unirgyInstance) { $giftCert = $unirgyInstance->get($giftcertCode); if ($giftCert && $giftCert->getStatus() === 'A' && $giftCert->getBalance() > 0) { $result = $giftCert->getBalance(); } } return (float) $result; }
[ "public", "function", "getUnirgyGiftCertBalanceByCode", "(", "$", "giftcertCode", ")", "{", "/** @var \\Unirgy\\Giftcert\\Model\\Cert $giftCert */", "$", "unirgyInstance", "=", "$", "this", "->", "unirgyCertRepository", "->", "getInstance", "(", ")", ";", "$", "result", ...
Get Unirgy_Giftcert balance. @param $giftcertCode @return float @throws \Magento\Framework\Exception\NoSuchEntityException
[ "Get", "Unirgy_Giftcert", "balance", "." ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Discount.php#L388-L402
train
BoltApp/bolt-magento2
Block/Js.php
Js.getTrackJsUrl
public function getTrackJsUrl() { $storeId = $this->getMagentoStoreId(); //Get cdn url $cdnUrl = $this->configHelper->getCdnUrl($storeId); return $cdnUrl.'/track.js'; }
php
public function getTrackJsUrl() { $storeId = $this->getMagentoStoreId(); //Get cdn url $cdnUrl = $this->configHelper->getCdnUrl($storeId); return $cdnUrl.'/track.js'; }
[ "public", "function", "getTrackJsUrl", "(", ")", "{", "$", "storeId", "=", "$", "this", "->", "getMagentoStoreId", "(", ")", ";", "//Get cdn url", "$", "cdnUrl", "=", "$", "this", "->", "configHelper", "->", "getCdnUrl", "(", "$", "storeId", ")", ";", "r...
Get track js url @return string
[ "Get", "track", "js", "url" ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Block/Js.php#L82-L89
train
BoltApp/bolt-magento2
Block/Js.php
Js.getReplaceSelectors
public function getReplaceSelectors() { $storeId = $this->getMagentoStoreId(); $subject = trim($this->configHelper->getReplaceSelectors($storeId)); return array_filter(explode(',', preg_replace('/\s+/', ' ', $subject))); }
php
public function getReplaceSelectors() { $storeId = $this->getMagentoStoreId(); $subject = trim($this->configHelper->getReplaceSelectors($storeId)); return array_filter(explode(',', preg_replace('/\s+/', ' ', $subject))); }
[ "public", "function", "getReplaceSelectors", "(", ")", "{", "$", "storeId", "=", "$", "this", "->", "getMagentoStoreId", "(", ")", ";", "$", "subject", "=", "trim", "(", "$", "this", "->", "configHelper", "->", "getReplaceSelectors", "(", "$", "storeId", "...
Get Replace Button Selectors. @return string
[ "Get", "Replace", "Button", "Selectors", "." ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Block/Js.php#L122-L128
train
BoltApp/bolt-magento2
Block/Js.php
Js.getInitiateCheckout
public function getInitiateCheckout() { $flag = $this->checkoutSession->getBoltInitiateCheckout(); $this->checkoutSession->unsBoltInitiateCheckout(); return (bool)$flag; }
php
public function getInitiateCheckout() { $flag = $this->checkoutSession->getBoltInitiateCheckout(); $this->checkoutSession->unsBoltInitiateCheckout(); return (bool)$flag; }
[ "public", "function", "getInitiateCheckout", "(", ")", "{", "$", "flag", "=", "$", "this", "->", "checkoutSession", "->", "getBoltInitiateCheckout", "(", ")", ";", "$", "this", "->", "checkoutSession", "->", "unsBoltInitiateCheckout", "(", ")", ";", "return", ...
Gets the auto-open Bolt checkout session flag, and then unsets it so that it is only used once. @return bool
[ "Gets", "the", "auto", "-", "open", "Bolt", "checkout", "session", "flag", "and", "then", "unsets", "it", "so", "that", "it", "is", "only", "used", "once", "." ]
1d91576a88ec3ea4748e5ccc755a580eecf5aff7
https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Block/Js.php#L194-L199
train