当前位置: 首页>>代码示例>>PHP>>正文


PHP cw_addons_set_hooks函数代码示例

本文整理汇总了PHP中cw_addons_set_hooks函数的典型用法代码示例。如果您正苦于以下问题:PHP cw_addons_set_hooks函数的具体用法?PHP cw_addons_set_hooks怎么用?PHP cw_addons_set_hooks使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了cw_addons_set_hooks函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: define

/*
 * Vendor:	CW
 * addon:	catalog_product
 * description:	
 *  New product type "Catalog" means that product is only listed on this site but can be bought on another site
 *  For this type of products the URL to real shop is required
 *  This product has special "buy" button in customer area, which may differ by appearance and text from normal products. For example it cat say "Buy from artist's site"
 *  Statistic about redirections to target site can be gathered as add_to_cart statistic (see "New statistic couner" spec)
 *  "Report as sold" feature is for this type of products only
 */
namespace CW\catalog_product;

const addon_name = 'catalog_product';
const addon_target = '';
const addon_version = '0.3';
define('PRODUCT_TYPE_CATALOG', 4);
cw_include('addons/' . addon_name . '/func.php');
if (APP_AREA == 'admin' && $target == 'products') {
    // Hook product modify to require Original URL attr for catalog product type
    cw_set_hook('cw_error_check', 'CW\\catalog_product\\cw_error_check', EVENT_POST);
    // Hook product modify to hide Original URL attr for other product types
    cw_addons_set_hooks(array('post', 'cw_attributes_get', 'CW\\catalog_product\\cw_attributes_get'));
}
if (APP_AREA == 'customer') {
    // Hook special catalog_redirect controller to redirect to original_url
    cw_set_controller('customer/catalog_redirect.php', 'addons/' . addon_name . '/customer/catalog_redirect.php', EVENT_REPLACE);
    cw_set_controller('customer/product.php', 'addons/' . addon_name . '/customer/product.php', EVENT_POST);
    cw_set_controller('customer/report_about_sold.php', 'addons/' . addon_name . '/customer/report_about_sold.php', EVENT_REPLACE);
    // hook for add_to_cart button to replace form, text and action
    cw_addons_set_template(array('pre', 'buttons/add_to_cart.tpl', 'addons/' . addon_name . '/add_to_cart.tpl', 'CW\\catalog_product\\cw_is_catalog_product'), array('pre', 'buttons/buy_now.tpl', 'addons/' . addon_name . '/buy_now.tpl', 'CW\\catalog_product\\cw_is_catalog_product'), array('replace', 'customer/products/product-amount.tpl', '', 'CW\\catalog_product\\cw_is_catalog_product'), array('pre', 'customer/products/product-fields.tpl', 'addons/' . addon_name . '/report_as_sold.tpl'));
}
开发者ID:CartworksPlatform,项目名称:cartworksplatform,代码行数:31,代码来源:init.php

示例2: cw_include

<?php

cw_include('addons/paypal/include/func.paypal.php');
cw_addons_set_controllers(array('replace', 'customer/paypal.php', 'addons/paypal/customer/paypal.php'));
cw_addons_set_template(array('post', 'main/docs/notes.tpl@doc_process_other', 'addons/paypal/admin/doc_process_data.tpl'));
cw_addons_set_hooks(array('post', 'cw_payment_get_methods', 'cw_payment_paypal_get_methods'), array('post', 'cw_payment_run_processor', 'cw_payment_paypal_run_processor'));
开发者ID:CartworksPlatform,项目名称:cartworksplatform,代码行数:6,代码来源:init.php

示例3: cw_apply_special_offer_shipping

function cw_apply_special_offer_shipping($params, $return)
{
    global $tables;
    $special_offers_apply =& cw_session_register('special_offers_apply');
    $products = $params['products'];
    if (empty($special_offers_apply['free_shipping'])) {
        return $return;
    }
    if (empty($return)) {
        return $return;
    }
    //cw_var_dump($return);
    $new_rates = array();
    // Re-calculate applicable total weight / items / subtotal	taking into account bonuses
    $total = $params['what_to_ship_params'];
    if (is_array($special_offers_apply['free_shipping']) && is_array($special_offers_apply['free_shipping']['products']) && !empty($special_offers_apply['free_shipping']['products'])) {
        $hash = crc32(serialize($total));
        foreach ($special_offers_apply['free_shipping']['products'] as $pid => $qty) {
            foreach ($products as $kk => $product) {
                if ($product['product_id'] == $pid) {
                    $tmp_qty = min($qty, $product['amount']);
                    if ($tmp_qty <= 0) {
                        continue;
                    }
                    # Calculate total_cost and total_+weight for shipping calculation
                    if ($product["free_shipping"] == "Y") {
                        continue;
                    }
                    if ($product['shipping_freight'] <= 0 || $config['Shipping']['replace_shipping_with_freight'] != 'Y') {
                        $total['apply']['weight'] -= $product["weight"] * $tmp_qty;
                        $total['apply']['items'] -= $tmp_qty;
                        $total['apply']['DST'] -= $product['display_discounted_price'] * $tmp_qty / $product['amount'];
                        $total['apply']['ST'] -= $product['display_subtotal'] * $tmp_qty / $product['amount'];
                        // Correct products array
                        $product['amount'] -= $tmp_qty;
                        $product['display_subtotal'] = $product['display_subtotal'] * $product['amount'] / ($tmp_qty + $product['amount']);
                        $product['display_discounted_price'] = $product['display_discounted_price'] * $product['amount'] / ($tmp_qty + $product['amount']);
                        $products[$kk] = $product;
                        if ($products[$kk]['amount'] <= 0) {
                            unset($products[$kk]);
                        }
                        $qty -= $tmp_qty;
                    }
                }
            }
        }
        if ($hash != crc32(serialize($total)) && $total['apply']['items'] > 0) {
            // Unset this function hook and retrieve rates again with corrected params
            cw_addons_unset_hooks(array('post', 'cw_shipping_get_rates', 'cw_apply_special_offer_shipping'));
            $_params = $params;
            $_params['what_to_ship_params'] = $total;
            $_params['weight'] = $total['apply']['weight'];
            $_params['products'] = $products;
            $new_rates = cw_func_call('cw_shipping_get_rates', $_params);
            // Restore function hook
            cw_addons_set_hooks(array('post', 'cw_shipping_get_rates', 'cw_apply_special_offer_shipping'));
        }
    }
    // Re-calc rates
    foreach ($return as $k => $rate) {
        // If bonus is applicable for certain methods only, then check this method
        if (!empty($special_offers_apply['free_shipping']['methods']) && is_array($special_offers_apply['free_shipping']['methods']) && !in_array($rate['shipping_id'], $special_offers_apply['free_shipping']['methods'])) {
            continue;
        }
        // If bonus is applicable for whole cart, then set the new rate regardless cart content
        if ($special_offers_apply['free_shipping']['apply'] == constant('PS_APPLY_CART')) {
            $return[$k]['saved_rate'] = $rate['original_rate'];
            // save initial rate to calc discount
            $return[$k]['original_rate'] = $special_offers_apply['free_shipping']['rate'];
            continue;
        }
        // If bonus is applicable for selected products then
        if (in_array($special_offers_apply['free_shipping']['apply'], array(PS_APPLY_COND, PS_APPLY_PRODS)) && !empty($special_offers_apply['free_shipping']['products'])) {
            if (isset($new_rates[$k])) {
                $return[$k] = $new_rates[$k];
            }
            if ($total['apply']['items'] <= 0) {
                $return[$k]['original_rate'] = 0;
            }
            $return[$k]['original_rate'] += $special_offers_apply['free_shipping']['rate'];
            $return[$k]['saved_rate'] = $rate['original_rate'];
            // save initial rate to calc discount
            if (defined('AOM') && constant('AOM')) {
                $return[$k]['shipping'] .= '*';
                //$return[$k]['shipping'] .= ' [offer: '.$rate['original_rate'].' => '.floatval($special_offers_apply['free_shipping']['rate']).'+'.floatval($new_rates[$k]['original_rate']).']';
            }
        }
    }
    // strange, but $rate['original_rate'] is exactly final rate value, not initial as you may think
    return $return;
}
开发者ID:CartworksPlatform,项目名称:cartworksplatform,代码行数:91,代码来源:func.php

示例4: option

<?php

# kornev, the product options are build on the attributes
# kornev, the product option - it's attribute, which have got the 'product_options' in the addon
# kornev, the option (as a class) is not assigned to a product - the values are assigned to the product
# kornev, the attribute -> product relation
$tables['product_options'] = 'cw_product_options';
$tables['product_options_lng'] = 'cw_product_options_lng';
$tables['product_options_values'] = 'cw_product_options_values';
$tables['product_options_values_lng'] = 'cw_product_options_values_lng';
$tables['product_variants'] = 'cw_product_variants';
$tables['product_variant_items'] = 'cw_product_variant_items';
$tables['products_options_ex'] = 'cw_products_options_ex';
$tables['product_options_js'] = 'cw_product_options_js';
$tables['products_images_var'] = 'cw_products_images_var';
cw_include('addons/product_options/include/func.product_options.php');
cw_include('addons/product_options/include/hooks.php', INCLUDE_NO_GLOBALS);
cw_addons_set_controllers(array('post', 'include/products/modify.php', 'addons/product_options/include/products/modify-options.php'), array('post', 'include/products/modify.php', 'addons/product_options/include/products/modify-variants.php'), array('replace', 'customer/popup_product_options.php', 'addons/product_options/customer/popup_product_options.php'), array('post', 'customer/product.php', 'addons/product_options/customer/product.php'));
cw_addons_set_hooks(array('post', 'cw_tabs_js_abstract', 'cw_product_options_tabs_js_abstract'), array('pre', 'cw_product_build_flat', 'cw_product_options_product_build_flat'), array('post', 'cw_product_build_flat', 'cw_product_options_product_build_flat_post'), array('pre', 'cw_product_check_avail', 'cw_product_options_product_check_avail'));
cw_addons_set_template(array('pre', 'customer/products/product-amount.tpl', 'addons/product_options/customer/products/product-amount.tpl'), array('replace', 'common/product_image.tpl', 'addons/product_options/customer/products/product_image.tpl'), array('post', 'customer/products/products-info.tpl', 'addons/product_options/customer/products/product-variant-selector.tpl'), array('pre', 'customer/products/products.tpl', 'addons/product_options/customer/products/products-prepare.tpl'));
cw_set_hook('cw_delete_product', 'cw_product_options_delete_product', EVENT_PRE);
cw_set_hook('cw_warehouse_recalculate', 'cw_on_warehouse_recalculate', EVENT_POST);
cw_set_hook('cw_product_clone', 'cw_product_options_clone', EVENT_POST);
cw_event_listen('on_prepare_products_found', 'cw_product_options_prepare_products_found');
开发者ID:CartworksPlatform,项目名称:cartworksplatform,代码行数:24,代码来源:init.php

示例5: array

    if (!file_exists($app_main_dir . '/seller')) {
        // There is no symlink /core/seller, map all files explicitly
        if (!($addon_hooks = cw_cache_get('seller', 'addon_hooks')) || defined('DEV_MODE')) {
            $addon_hooks = array();
            $files = cw_files_get_dir($app_main_dir . '/addons/seller/core', 1, false);
            foreach ($files as $file) {
                if (strpos($file, '.php') !== false) {
                    $file = str_replace($app_main_dir . '/addons/seller/core/', '', $file);
                    $addon_hooks[] = $file;
                }
            }
            cw_cache_save($addon_hooks, 'seller', 'addon_hooks');
        }
        foreach ($addon_hooks as $h) {
            cw_set_controller("seller/{$h}", 'addons/' . seller_addon_name . "/core/{$h}", EVENT_REPLACE);
        }
    } else {
        // Symlink is used, everything mapped by filesystem
    }
    cw_set_controller(APP_AREA . '/products_clients.php', 'admin/products_clients.php', EVENT_REPLACE);
    cw_set_controller(APP_AREA . '/products.php', 'addons/' . seller_addon_name . '/core/search.php', EVENT_PRE);
    cw_addons_set_hooks(array('pre', 'cw_product_search', 'cw_seller_product_search'), array('replace', 'cw_auth_check_security_targets', 'cw_seller_auth_check_security_targets'));
    cw_addons_set_template(array('replace', APP_AREA . '/main/main.tpl', 'addons/' . seller_addon_name . '/main/main.tpl'), array('replace', 'elements/auth_admin.tpl', 'addons/' . seller_addon_name . '/elements/auth.tpl'), array('replace', 'main/products/search_form.tpl', 'addons/' . seller_addon_name . '/products/search_form.tpl'), array('replace', 'menu/items.tpl', 'addons/' . seller_addon_name . '/menu/items.tpl'), array('replace', APP_AREA . '/products/product_modify.tpl', 'addons/' . seller_addon_name . '/products/product_modify.tpl'), array('replace', APP_AREA . '/products/product_add.tpl', 'addons/' . seller_addon_name . '/products/product_add.tpl'), array('replace', APP_AREA . '/products/search.tpl', 'addons/' . seller_addon_name . '/products/search.tpl'), array('replace', APP_AREA . '/products/customers.tpl', 'admin/products/customers.tpl'), array());
    // Orders
    cw_addons_set_template(array('replace', APP_AREA . '/orders/orders.tpl', 'admin/orders/orders.tpl'), array('replace', APP_AREA . '/orders/document.tpl', 'admin/orders/document.tpl'), array('replace', 'main/docs/notes.tpl', 'addons/' . seller_addon_name . '/orders/notes.tpl'));
    // Profile
    cw_addons_set_template(array('replace', 'main/users/sections/basic.tpl', 'addons/' . seller_addon_name . '/sections/basic.tpl'), array('replace', APP_AREA . '/acc_manager/acc_manager.tpl', 'addons/' . seller_addon_name . '/acc_manager/acc_manager.tpl'), array('replace', APP_AREA . '/acc_manager/modify.tpl', 'addons/' . seller_addon_name . '/acc_manager/modify.tpl'), array());
    if ($target == 'products' && $mode == 'details') {
        cw_addons_set_template(array('replace', 'main/select/availability.tpl', 'addons/' . seller_addon_name . '/main/select/availability.tpl', 'cw_seller_product_is_pending'));
    }
}
开发者ID:CartworksPlatform,项目名称:cartworksplatform,代码行数:31,代码来源:init.php

示例6: cw_addons_set_hooks

<?php

cw_addons_set_hooks(array('post', 'cw_shipping_get_rates', 'cw_apply_special_offer_shipping'));
cw_event_listen('on_collect_shipping_rates_hash', 'cw_ps_on_collect_shipping_rates_hash', EVENT_POST);
开发者ID:CartworksPlatform,项目名称:cartworksplatform,代码行数:4,代码来源:post_init.php

示例7: cw_addons_set_controllers

<?php

$tables['linked_products'] = 'cw_linked_products';
require $app_main_dir . '/addons/accessories/func.php';
require $app_main_dir . '/addons/accessories/func.hooks.php';
if (APP_AREA == 'admin') {
    cw_addons_set_controllers(array('pre', 'include/products/modify.php', 'addons/accessories/product_modify_accessories.php'));
    cw_addons_set_hooks(array('post', 'cw_tabs_js_abstract', 'cw_ac_tabs_js_abstract'));
    cw_set_hook('cw_product_clone', 'cw_ac_product_clone', EVENT_POST);
    cw_set_hook('cw_delete_product', 'cw_ac_delete_product', EVENT_POST);
}
if (APP_AREA == 'customer') {
    //cw_addons_add_js('addons/accessories/func.js');
    cw_addons_set_controllers(array('post', 'customer/product.php', 'addons/accessories/product_accessories.php'));
    cw_set_controller('customer/product.php', 'addons/accessories/rv_product.php', EVENT_POST);
    cw_set_controller('customer/cart.php', 'addons/accessories/rv_products_list.php', EVENT_POST);
    cw_set_controller('customer/cart.php', 'addons/accessories/cab_products_list.php', EVENT_POST);
    cw_addons_set_template(array('post', 'customer/cart/cart.tpl', 'addons/accessories/cart_recently_viewed_products.tpl'), array('post', 'customer/cart/cart.tpl', 'addons/accessories/cab_products_list.tpl'));
    cw_addons_set_hooks(array('post', 'cw_tabs_js_abstract', 'cw_ac_tabs_js_abstract'));
    // Integration with ajax_add2cart addon {
    if (defined('IS_AJAX') && constant('IS_AJAX')) {
        cw_event_listen('on_add_cart', 'cw_ac_on_add_to_cart');
        cw_addons_set_template(array('post', 'addons/ajax_add2cart/add2cart_popup.tpl', 'addons/accessories/add2cart_popup.tpl'));
    }
    // } Integration with ajax_add2cart addon
    cw_addons_add_css('addons/accessories/accessories.css');
}
开发者ID:CartworksPlatform,项目名称:cartworksplatform,代码行数:27,代码来源:init.php


注:本文中的cw_addons_set_hooks函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。