gocommerce

package module
v0.0.0-...-5d90f16 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 16, 2025 License: MIT Imports: 16 Imported by: 2

README

Golang Commerce Interface

Go config parsers for several PHP eCommerce platforms:

  • Magento 1
  • Magento 2
  • Wordpress/Woocommerce

Documentation

Index

Constants

View Source
const (
	// DATABASE_URL=mysql://db-user-1:rhPb5xC2242444mFZDB@localhost:3306/db-1
	DBURL = `(?m)^\s*DATABASE_URL\s*="?\s*mysql://(.+?):(.+?)@(.+?):(\d+)/(.+?)"?$`
)

Variables

View Source
var AllPlatforms = []PlatformInterface{
	&Magento1{
		basePlatform{
			"Magento 1",
			"app/etc/local.xml",
			"app/etc/local.xml",
		},
		"n98-magerun",
	},
	&Magento2{
		basePlatform{
			"Magento 2",
			"app/etc/env.php",
			"app/etc/env.php",
		},
		"n98-magerun2",
	},
	&Shopware5{
		basePlatform{
			"Shopware 5",
			"config.php",
			"engine/Shopware/Application.php",
		},
	},
	&Shopware6{
		basePlatform{
			"Shopware 6",
			".env",
			"vendor/shopware/core/Framework/ShopwareException.php",
		},
	},
	&Prestashop6{
		basePlatform{
			"Prestashop 6",
			"config/settings.inc.php",
			"config/settings.inc.php",
		},
	},
	&Prestashop7{
		basePlatform{
			"Prestashop 7",
			"app/config/parameters.php",
			"app/config/parameters.php",
		},
	},
	&WooCommerce{
		basePlatform{
			"WooCommerce",
			"wp-config.php",
			"wp-config.php",
		},
	},
	&OpenCart4{
		basePlatform{
			"OpenCart 4",
			"config.php",
			"system/engine/config.php",
		},
	},
}

Functions

func ConnectDB

func ConnectDB(ctx context.Context, cfg DBConfig) (*sql.DB, error)

NB copy StoreConfig, as we may modify it

Types

type DBConfig

type DBConfig struct {
	Host   string
	User   string
	Pass   string
	Name   string
	Prefix string
	Port   int
}

func (*DBConfig) DSN

func (c *DBConfig) DSN() string

func (*DBConfig) SafePrefix

func (c *DBConfig) SafePrefix() (string, error)

type Magento1

type Magento1 struct {
	Magerun string
	// contains filtered or unexported fields
}

func (*Magento1) BaseURLs

func (m1 *Magento1) BaseURLs(ctx context.Context, docroot string) ([]string, error)

func (*Magento1) ConfigPath

func (b *Magento1) ConfigPath() string

func (*Magento1) Name

func (b *Magento1) Name() string

func (*Magento1) ParseConfig

func (m1 *Magento1) ParseConfig(cfgPath string) (*StoreConfig, error)

func (*Magento1) UniquePath

func (b *Magento1) UniquePath() string

func (*Magento1) Version

func (m1 *Magento1) Version(docroot string) (string, error)

type Magento2

type Magento2 struct {
	Magerun string
	// contains filtered or unexported fields
}

func (*Magento2) BaseURLs

func (m2 *Magento2) BaseURLs(ctx context.Context, docroot string) ([]string, error)

func (*Magento2) ConfigPath

func (b *Magento2) ConfigPath() string

func (*Magento2) Name

func (b *Magento2) Name() string

func (*Magento2) ParseConfig

func (m2 *Magento2) ParseConfig(cfgPath string) (*StoreConfig, error)

func (*Magento2) UniquePath

func (b *Magento2) UniquePath() string

func (*Magento2) Version

func (m2 *Magento2) Version(docroot string) (string, error)

type OpenCart4

type OpenCart4 struct {
	// contains filtered or unexported fields
}

func (*OpenCart4) BaseURLs

func (oc4 *OpenCart4) BaseURLs(_ context.Context, docroot string) ([]string, error)

func (*OpenCart4) ConfigPath

func (b *OpenCart4) ConfigPath() string

func (*OpenCart4) Name

func (b *OpenCart4) Name() string

func (*OpenCart4) ParseConfig

func (oc4 *OpenCart4) ParseConfig(cfgPath string) (*StoreConfig, error)

func (*OpenCart4) UniquePath

func (b *OpenCart4) UniquePath() string

func (*OpenCart4) Version

func (oc4 *OpenCart4) Version(docroot string) (string, error)

type PlatformInterface

type PlatformInterface interface {
	Name() string
	ParseConfig(cfgPath string) (*StoreConfig, error)
	Version(docroot string) (string, error)
	BaseURLs(ctx context.Context, docroot string) ([]string, error)
	ConfigPath() string
	UniquePath() string
}

type Prestashop6

type Prestashop6 struct {
	// contains filtered or unexported fields
}

func (*Prestashop6) BaseURLs

func (b *Prestashop6) BaseURLs(_ context.Context, _ string) ([]string, error)

func (*Prestashop6) ConfigPath

func (b *Prestashop6) ConfigPath() string

func (*Prestashop6) Name

func (b *Prestashop6) Name() string

func (*Prestashop6) ParseConfig

func (p *Prestashop6) ParseConfig(cfgPath string) (*StoreConfig, error)

func (*Prestashop6) UniquePath

func (b *Prestashop6) UniquePath() string

func (*Prestashop6) Version

func (b *Prestashop6) Version(_ string) (string, error)

type Prestashop7

type Prestashop7 struct {
	// contains filtered or unexported fields
}

func (*Prestashop7) BaseURLs

func (b *Prestashop7) BaseURLs(_ context.Context, _ string) ([]string, error)

func (*Prestashop7) ConfigPath

func (b *Prestashop7) ConfigPath() string

func (*Prestashop7) Name

func (b *Prestashop7) Name() string

func (*Prestashop7) ParseConfig

func (p *Prestashop7) ParseConfig(cfgPath string) (*StoreConfig, error)

func (*Prestashop7) UniquePath

func (b *Prestashop7) UniquePath() string

func (*Prestashop7) Version

func (b *Prestashop7) Version(_ string) (string, error)

type Shopware5

type Shopware5 struct {
	// contains filtered or unexported fields
}

func (*Shopware5) BaseURLs

func (b *Shopware5) BaseURLs(_ context.Context, _ string) ([]string, error)

func (*Shopware5) ConfigPath

func (b *Shopware5) ConfigPath() string

func (*Shopware5) Name

func (b *Shopware5) Name() string

func (*Shopware5) ParseConfig

func (b *Shopware5) ParseConfig(_ string) (*StoreConfig, error)

func (*Shopware5) UniquePath

func (b *Shopware5) UniquePath() string

func (*Shopware5) Version

func (b *Shopware5) Version(_ string) (string, error)

type Shopware6

type Shopware6 struct {
	// contains filtered or unexported fields
}

func (*Shopware6) BaseURLs

func (s *Shopware6) BaseURLs(ctx context.Context, docroot string) ([]string, error)

func (*Shopware6) ConfigPath

func (b *Shopware6) ConfigPath() string

func (*Shopware6) Name

func (b *Shopware6) Name() string

func (*Shopware6) ParseConfig

func (s *Shopware6) ParseConfig(cfgPath string) (*StoreConfig, error)

func (*Shopware6) UniquePath

func (b *Shopware6) UniquePath() string

func (*Shopware6) Version

func (s *Shopware6) Version(docroot string) (string, error)

type Store

type Store struct {
	DocRoot  string
	Platform PlatformInterface
	Config   *StoreConfig
}

func DiscoverStores

func DiscoverStores() []*Store

DiscoverStores searches several common docroot locations for stores

func FindStoreAtRoot

func FindStoreAtRoot(docroot string) *Store

func FindStoreAtUniquePath

func FindStoreAtUniquePath(path string) *Store

For recursively walking the filesystem: derive a store from a uniquely identifying path

func (*Store) ConfigPath

func (s *Store) ConfigPath() string

type StoreConfig

type StoreConfig struct {
	DB        *DBConfig
	AdminSlug string
}

type WooCommerce

type WooCommerce struct {
	// contains filtered or unexported fields
}

func (*WooCommerce) BaseURLs

func (w *WooCommerce) BaseURLs(ctx context.Context, docroot string) ([]string, error)

func (*WooCommerce) ConfigPath

func (b *WooCommerce) ConfigPath() string

func (*WooCommerce) Name

func (b *WooCommerce) Name() string

func (*WooCommerce) ParseConfig

func (w *WooCommerce) ParseConfig(cfgPath string) (*StoreConfig, error)

func (*WooCommerce) UniquePath

func (b *WooCommerce) UniquePath() string

func (*WooCommerce) Version

func (w *WooCommerce) Version(docroot string) (string, error)

Directories

Path Synopsis
cmd
find command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL