scopeConfig = $scopeConfig; $this->deliveryTermConfig = $deliveryTermConfig; } /** * Retrieve which price we should be applying tax to * * @param null $store * @param string $scope * @return string */ public function getApplyTaxOn($store = null, $scope = ScopeInterface::SCOPE_STORE) { return $this->getConfigValue(self::CONFIG_XML_PATH_TAX_APPLY_ON, $store, $scope); } /** * Get the City of the Company Address * * @param string|null $store * @param string $scope * @return float|null */ public function getCompanyCity($store = null, $scope = ScopeInterface::SCOPE_STORE) { return $this->getConfigValue(self::CONFIG_XML_PATH_VERTEX_CITY, $store, $scope); } /** * Retrieve the Company Code * * @param string|null $store * @param string $scope * @return float|null */ public function getCompanyCode($store = null, $scope = ScopeInterface::SCOPE_STORE) { return $this->getConfigValue(self::CONFIG_XML_PATH_VERTEX_COMPANY_CODE, $store, $scope); } /** * Get the Country of the Company Address * * @param string|null $store * @param string $scope * @return bool|float|null */ public function getCompanyCountry($store = null, $scope = ScopeInterface::SCOPE_STORE) { $country = $this->getConfigValue(self::CONFIG_XML_PATH_VERTEX_COUNTRY, $store, $scope); return $country !== null ? $country : false; } /** * Get the Postal Code of the Company Address * * @param string|null $store * @param string $scope * @return float|null */ public function getCompanyPostalCode($store = null, $scope = ScopeInterface::SCOPE_STORE) { return $this->getConfigValue(self::CONFIG_XML_PATH_VERTEX_POSTAL_CODE, $store, $scope); } /** * Get the Region ID of the Company Address * * @param string|null $store * @param string $scope * @return bool|float|null */ public function getCompanyRegionId($store = null, $scope = ScopeInterface::SCOPE_STORE) { $region = $this->getConfigValue(self::CONFIG_XML_PATH_VERTEX_REGION, $store, $scope); return $region !== null ? $region : false; } /** * Get Line 1 of the Company Street Address * * @param string|null $store * @param string $scope * @return float|null */ public function getCompanyStreet1($store = null, $scope = ScopeInterface::SCOPE_STORE) { return $this->getConfigValue(self::CONFIG_XML_PATH_VERTEX_STREET1, $store, $scope); } /** * Get Line 2 of the Company Street Address * * @param string|null $store * @param string $scope * @return float|null */ public function getCompanyStreet2($store = null, $scope = ScopeInterface::SCOPE_STORE) { return $this->getConfigValue(self::CONFIG_XML_PATH_VERTEX_STREET2, $store, $scope); } /** * Retrieve a value from the configuration within a scope * * @param string $value * @param string|null $scopeId * @param string|null $scope * @return mixed */ public function getConfigValue($value, $scopeId = null, $scope = ScopeInterface::SCOPE_STORE) { return $this->scopeConfig->getValue($value, $scope, $scopeId); } /** * Get the Tax class for a creditmemo adjustment fee * * @param string|null $store * @param string $scope * @return float|null */ public function getCreditmemoAdjustmentFeeClass($store = null, $scope = ScopeInterface::SCOPE_STORE) { return $this->getConfigValue(self::VERTEX_CREDITMEMO_ADJUSTMENT_CLASS, $store, $scope); } /** * Get the code for a creditmemo adjustment fee * * @param string|null $store * @param string $scope * @return float|null */ public function getCreditmemoAdjustmentFeeCode($store = null, $scope = ScopeInterface::SCOPE_STORE) { return $this->getConfigValue(self::VERTEX_CREDITMEMO_ADJUSTMENT_NEGATIVE_CODE, $store, $scope); } /** * Get the tax class for a positive adjustment on a creditmemo * * @param string|null $store * @param string $scope * @return float|null */ public function getCreditmemoAdjustmentPositiveClass($store = null, $scope = ScopeInterface::SCOPE_STORE) { return $this->getConfigValue(self::VERTEX_CREDITMEMO_ADJUSTMENT_CLASS, $store, $scope); } /** * Get the positive adjustment code for a creditmemo * * @param string|null $store * @param string $scope * @return float|null */ public function getCreditmemoAdjustmentPositiveCode($store = null, $scope = ScopeInterface::SCOPE_STORE) { return $this->getConfigValue(self::VERTEX_CREDITMEMO_ADJUSTMENT_POSITIVE_CODE, $store, $scope); } /** * Retrieve the frequency at which the cron should run * * @return string */ public function getCronRotationFrequency() { return $this->getConfigValue(self::CONFIG_XML_PATH_VERTEX_LOG_ROTATION_FREQUENCY); } /** * Retrieve the time of day logs should be rotated * * @return string */ public function getCronRotationTime() { return $this->getConfigValue(self::CONFIG_XML_PATH_VERTEX_LOG_ROTATION_RUNTIME); } /** * Retrieve the lifetime of logs, in days, before they are rotated * * @return string */ public function getCronLogLifetime() { return $this->getConfigValue(self::VERTEX_LOG_LIFETIME_DAYS); } /** * Get the Default Customer Code * * @param string|null $store * @param string $scope * @return float|null */ public function getDefaultCustomerCode($store = null, $scope = ScopeInterface::SCOPE_STORE) { return $this->getConfigValue(self::CONFIG_XML_PATH_DEFAULT_CUSTOMER_CODE, $store, $scope); } /** * Get the default Delivery Term * * @param string|null $store * @param string $scope * @return string */ public function getDefaultDeliveryTerm($store = null, $scope = ScopeInterface::SCOPE_WEBSITE) { return $this->getConfigValue(self::CONFIG_XML_PATH_VERTEX_DELIVERY_TERM_DEFAULT, $store, $scope); } /** * Get the Delivery Term to Override * * @param string|null $store * @param string $scope * @return array */ public function getDeliveryTermOverride($store = null, $scope = ScopeInterface::SCOPE_WEBSITE) { $configValue = $this->getConfigValue(self::CONFIG_XML_PATH_VERTEX_DELIVERY_TERM_OVERRIDE, $store, $scope); return $this->deliveryTermConfig->unserializeValue($configValue); } /** * Get the Tax Class for Item-level Giftwrapping * * @param string|null $store * @param string $scope * @return float|null */ public function getGiftWrappingItemClass($store = null, $scope = ScopeInterface::SCOPE_STORE) { return $this->getConfigValue(self::VERTEX_GIFTWRAP_ITEM_CLASS, $store, $scope); } /** * Get the code prefix for Item-level Giftwrapping * * @param string|null $store * @param string $scope * @return float|null */ public function getGiftWrappingItemCodePrefix($store = null, $scope = ScopeInterface::SCOPE_STORE) { return $this->getConfigValue(self::VERTEX_GIFTWRAP_ITEM_CODE_PREFIX, $store, $scope); } /** * Get the Tax Class for Order-level Giftwrapping * * @param string|null $store * @param string $scope * @return float|null */ public function getGiftWrappingOrderClass($store = null, $scope = ScopeInterface::SCOPE_STORE) { return $this->getConfigValue(self::VERTEX_GIFTWRAP_ORDER_CLASS, $store, $scope); } /** * Get the code for Order-level Giftwrapping * * @param string|null $store * @param string $scope * @return float|null */ public function getGiftWrappingOrderCode($store = null, $scope = ScopeInterface::SCOPE_STORE) { return $this->getConfigValue(self::VERTEX_GIFTWRAP_ORDER_CODE, $store, $scope); } /** * Retrieve the Location Code * * @param string|null $store * @param string $scope * @return float|null */ public function getLocationCode($store = null, $scope = ScopeInterface::SCOPE_STORE) { return $this->getConfigValue(self::CONFIG_XML_PATH_VERTEX_LOCATION_CODE, $store, $scope); } /** * Retrieve the price of a Printed Gift Card * * @param string|null $store * @param string $scope * @return mixed */ public function getPrintedCardPrice($store = null, $scope = ScopeInterface::SCOPE_STORE) { return $this->getConfigValue(self::CONFIG_XML_PATH_PRINTED_CARD_PRICE, $store, $scope); } /** * Get the Tax Class for a Printed Gift Card * * @param string|null $store * @param string $scope * @return float|null */ public function getPrintedGiftcardClass($store = null, $scope = ScopeInterface::SCOPE_STORE) { return $this->getConfigValue(self::VERTEX_PRINTED_GIFTCARD_CLASS, $store, $scope); } /** * Get the code for a Printed Gift Card * * @param string|null $store * @param string $scope * @return float|null */ public function getPrintedGiftcardCode($store = null, $scope = ScopeInterface::SCOPE_STORE) { return $this->getConfigValue(self::VERTEX_PRINTED_GIFTCARD_CODE, $store, $scope); } /** * Retrieve the type of action to take to logs when rotating * * @return string|null */ public function getRotationAction() { return $this->getConfigValue(self::CONFIG_XML_PATH_ROTATION_ACTION); } /** * Get the Tax Class ID to be used for Shipping * * @param string|null $store * @param string $scope * @return float|null */ public function getShippingTaxClassId($store = null, $scope = ScopeInterface::SCOPE_STORE) { return $this->getConfigValue(self::CONFIG_XML_PATH_SHIPPING_TAX_CLASS, $store, $scope); } /** * Get the Trusted ID for the Vertex Integration * * @param string|null $store * @param string $scope * @return float|null */ public function getTrustedId($store = null, $scope = ScopeInterface::SCOPE_STORE) { return $this->getConfigValue(self::CONFIG_XML_PATH_VERTEX_API_TRUSTED_ID, $store, $scope); } /** * Get the URL of the Tax Area Lookup API Endpoint * * @param string|null $store * @param string $scope * @return float|null */ public function getVertexAddressHost($store = null, $scope = ScopeInterface::SCOPE_STORE) { return $this->getConfigValue(self::VERTEX_ADDRESS_API_HOST, $store, $scope); } /** * Get the URL of the Quotation and Invoicing API Endpoint * * @param string|null $store * @param string $scope * @return float|null */ public function getVertexHost($store = null, $scope = ScopeInterface::SCOPE_STORE) { return $this->getConfigValue(self::VERTEX_API_HOST, $store, $scope); } /** * Grab the Order Status during which we should commit to the Tax Log * * @param string|null $store * @param string $scope * @return string */ public function invoiceOrderStatus($store = null, $scope = ScopeInterface::SCOPE_STORE) { return $this->getConfigValue(self::CONFIG_XML_PATH_VERTEX_INVOICE_ORDER_STATUS, $store, $scope); } /** * Determine if Vertex Logging has been enabled * * @param string|null $scopeCode * @param string $scope * @return bool */ public function isLoggingEnabled($scopeCode = null, $scope = ScopeInterface::SCOPE_STORE) { return $this->scopeConfig->isSetFlag(self::CONFIG_XML_PATH_LOGGING_ENABLED, $scope, $scopeCode); } /** * Retrieve a list of countries grouped by Vertex region * * @param string|null $store * @param string $scope * @return array A multi-dimensional array where the top level key is the Vertex region the country is associated * with and the value is an array of country codes */ public function getListForAllowedCountrySort($store = null, $scope = ScopeInterface::SCOPE_STORE) { $returnArray = json_decode($this->getConfigValue(self::VERTEX_COUNTRY_SORT_REGION, $store, $scope), true); return $returnArray ?: []; } /** * Retrieve list of countries Vertex should be used for * * @param string|null $store * @param string $scope * @return string[] of two character ISO country codes */ public function getAllowedCountries($store = null, $scope = ScopeInterface::SCOPE_STORE) { return explode(',', $this->getConfigValue(self::VERTEX_ALLOWED_COUNTRIES, $store, $scope)); } /** * Determine whether or not tax is turned on to display in the catalog * * @param string|null $store * @param string $scope * @return bool */ public function isDisplayPriceInCatalogEnabled($store = null, $scope = ScopeInterface::SCOPE_STORE) { $configValue = $this->getConfigValue(self::CONFIG_XML_PATH_TAX_DISPLAY_IN_CATALOG, $store, $scope); return (int)$configValue !== TaxConfig::DISPLAY_TYPE_EXCLUDING_TAX; } /** * Determine if Vertex has been enabled * * @param string|null $scopeId * @param string $scope * @return bool */ public function isVertexActive($scopeId = null, $scope = ScopeInterface::SCOPE_STORE) { return $this->scopeConfig->isSetFlag(self::CONFIG_XML_PATH_ENABLE_VERTEX, $scope, $scopeId); } /** * Determine if tax calculation is enabled * * @param string|null $scopeId * @param string $scope * @return bool */ public function isTaxCalculationEnabled($scopeId = null, $scope = ScopeInterface::SCOPE_STORE) { return $this->scopeConfig->isSetFlag(self::CONFIG_XML_PATH_ENABLE_TAX_CALCULATION, $scope, $scopeId); } /** * Determine if Vertex Archiving has been enabled. * * @return bool */ public function isLogRotationEnabled() { return $this->scopeConfig->isSetFlag( self::CONFIG_XML_PATH_VERTEX_ENABLE_LOG_ROTATION, ScopeConfigInterface::SCOPE_TYPE_DEFAULT ); } /** * Determine if we commit to the Tax Log during Invoice Creation or not * * @param string|null $store * @param string $scope * @return bool */ public function requestByInvoiceCreation($store = null, $scope = ScopeInterface::SCOPE_STORE) { $vertexInvoiceEvent = $this->getConfigValue(self::CONFIG_XML_PATH_VERTEX_INVOICE_ORDER, $store, $scope); return $vertexInvoiceEvent === 'invoice_created'; } /** * Determine if we commit to the Tax Log during an Order Status change or not * * @param string|null $store * @param string $scope * @return bool */ public function requestByOrderStatus($store = null, $scope = ScopeInterface::SCOPE_STORE) { $vertexInvoiceEvent = $this->getConfigValue(self::CONFIG_XML_PATH_VERTEX_INVOICE_ORDER, $store, $scope); return $vertexInvoiceEvent === 'order_status'; } /** * Determine how customer receive their tax summaries * * @param string|null $store * @param string $scope * @return string */ public function getSummarizeTax($store = null, $scope = ScopeInterface::SCOPE_STORE) { return $this->getConfigValue(self::VERTEX_SUMMARIZE_TAX, $store, $scope); } }